Skip to content

Instantly share code, notes, and snippets.

@fpdjsns
Created February 24, 2019 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpdjsns/3e0a056c21886042e7ea2b1233ed9310 to your computer and use it in GitHub Desktop.
Save fpdjsns/3e0a056c21886042e7ea2b1233ed9310 to your computer and use it in GitHub Desktop.
Mural
//
// Created by fpdjsns
// Copyright © 2019 fpdjsns. All rights reserved.
//
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
int T;
cin >> T;
for (int c = 1; c <= T; c++) {
int N;
cin >> N;
string s;
cin >> s;
vector<long long int> sum(N + 1, 0);
for (int i = 1; i <= N; i++) {
sum[i] += sum[i - 1] + s[i - 1] - '0';
}
long long int answer = 0;
long long int cnt = (N + 1) / 2;
for (int i = cnt; i <= N; i++) {
answer = max(answer, sum[i] - sum[i - cnt]);
}
printf("Case #%d: ", c);
cout << answer << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment