Submission #206147

#TimeUsernameProblemLanguageResultExecution timeMemory
206147luciocfPreokret (COCI19_preokret)C++14
49 / 50
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 255; int a[maxn]; int main(void) { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); int q1 = 0, q2 = 0, emp = 0; int turn = 0; for (int i = 1; i <= n; i++) { if (q1 == q2) emp++; if (q1 <= q2 && a[i] == 1) { int j; for (j = i; j <= n && a[j] == 1; j++) ; j--; if (q1+j-i+1 > q2) turn = max(turn, j-i+1); } else if (q2 <= q1 && a[i] == 2) { int j; for (j = i; j <= n && a[j] == 2; j++) ; j--; if (q2+j-i+1 > q1) turn = max(turn, j-i+1); } if (a[i] == 1) q1++; else q2++; } printf("%d %d\n%d\n%d\n", q1, q2, emp, turn); }

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
preokret.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...