# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223615 | Haunted_Cpp | Preokret (COCI19_preokret) | C++17 | 5 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstring>
#include <algorithm>
#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a = 0, b = 0, res = 1, turnaround = 0, streak = 0, last = -1;
auto update = [&] () {
if (last == 1 && a > b) {
turnaround = max (turnaround, streak);
}
if (last == 2 && b > a) {
turnaround = max (turnaround, streak);
}
};
for (int i = 0; i < n; i++) {
int foo;
cin >> foo;
if (foo == last) {
++streak;
update ();
} else {
update ();
streak = 1;
}
last = foo;
if (foo == 1) ++a;
else ++b;
res += (a == b);
}
update ();
cout << a << ' ' << b << '\n';
cout << res << '\n';
cout << turnaround << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |