Submission #198273

# Submission time Handle Problem Language Result Execution time Memory
198273 2020-01-25T09:50:20 Z alrad Preokret (COCI19_preokret) C++17
50 / 50
10 ms 504 KB
#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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 1 ms 348 KB Output is correct