-
-
Save fpdjsns/3e0a056c21886042e7ea2b1233ed9310 to your computer and use it in GitHub Desktop.
Mural
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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