이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |