#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
const int MXN = 255;
int n, a[MXN];
pii sc[MXN];
int TIE() {
int ans = 0;
for (int i = 0; i <= n; i++) if (sc[i].first == sc[i].second) ans++;
return ans;
}
int TURN() {
int ans = 0;
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && a[i] == a[j]) j++;
if (a[i] == 1) {
if (sc[i].first < sc[i].second && sc[j].first > sc[j].second) ans = max(ans, j - i);
} else {
if (sc[i].first > sc[i].second && sc[j].first < sc[j].second) ans = max(ans, j - i);
}
}
return ans;
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
sc[i + 1] = sc[i];
if (a[i] == 1) sc[i + 1].first++;
else sc[i + 1].second++;
}
cout << sc[n].first << ' ' << sc[n].second << endl;
cout << TIE() << endl;
cout << TURN() << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |