#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define T int t; cin >> t; while(t--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 205;
const int M = 1e3 + 3;
const int inf = 1e18;
const int mod = 1e9 + 7;
int n, team1, team2;
main() {
IOS
cin >> n;
int cnt1 = 0, cnt2 = 0, mx = 0, tie = 1;
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
if (x == 1) {
cnt1++;
cnt2 = 0;
team1++;
if (team1 > team2 && team1 - cnt1 < team2)
mx = max(mx, cnt1);
}
else {
cnt2++;
cnt1 = 0;
team2++;
if (team2 > team1 && team2 - cnt2 < team1)
mx = max(mx, cnt2);
}
tie += team1 == team2;
}
cout << team1 << ' ' << team2 << '\n' << tie << '\n' << mx;
}
Compilation message
preokret.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |