/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 26ms 552.0 KiB
#3 Accepted 7ms 324.0 KiB
#4 Accepted 4ms 516.0 KiB
#5 Accepted 6ms 584.0 KiB
#6 Accepted 6ms 676.0 KiB
#7 Accepted 6ms 804.0 KiB
#8 Accepted 6ms 760.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	int t;	cin >> t;
	while(t--){
		ll n;
		cin >> n;
		string s;	cin >> s;
		ll one = 0, pone = 0;
		for(ll i=0;i<n;i++)	s[i] == '0' ? s[i] = '1' : s[i] = '0';
		for(ll i = 0;i<n;i++){
			if(s[i] == '1')	one++;
			else{
				pone = max(pone,one);
				one = 0;
			}
		}
		cout << max(pone,one) << endl;
	}
	return 0;
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 15:01:33
Judged At
2024-11-11 02:31:47
Judged By
Score
100
Total Time
26ms
Peak Memory
804.0 KiB