Submission #198273

#TimeUsernameProblemLanguageResultExecution timeMemory
198273alradPreokret (COCI19_preokret)C++17
50 / 50
10 ms504 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int n; cin >> n; int a = 0 , b = 0; int ties = 1; vector<int> tot; for (int i = 1; i <= n; i++) { int x; cin >> x; tot.push_back(x); (x == 1 ? a++ : b++); if (a == b) { ties++; } } cout << a << " " << b << '\n'; cout << ties << '\n'; a = b = 0; int turnover = 0; for (int i = 0; i < n; i++) { (tot[i] == 1 ? a++ : b++); int scored_a = 0 , scored_b = 0; for (int j = i + 1; j < n; j++) { (tot[j] == 1 ? scored_a++ : scored_b++); if (j != i + 1 && tot[j] != tot[j - 1]) { break; } if (a < b) { if (a + scored_a > b + scored_b) { turnover = max(turnover , scored_a); } } else if (b < a) { if (b + scored_b > a + scored_a) { turnover = max(turnover , scored_b); } } } } cout << turnover << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...