Submission #223615

#TimeUsernameProblemLanguageResultExecution timeMemory
223615Haunted_CppPreokret (COCI19_preokret)C++17
50 / 50
5 ms384 KiB
#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 timeMemoryGrader output
Fetching results...