Submission #811148

#TimeUsernameProblemLanguageResultExecution timeMemory
811148PringPreokret (COCI19_preokret)C++14
50 / 50
0 ms212 KiB
#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 timeMemoryGrader output
Fetching results...