Submission #481170

#TimeUsernameProblemLanguageResultExecution timeMemory
481170rainboyPreokret (COCI19_preokret)C11
50 / 50
1 ms276 KiB
#include <stdio.h> #define N 250 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N]; int n, i, j, a, b, t, l; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); a = 0, b = 0, t = 1, l = 0; for (i = 0; i < n; i = j) { int c; j = i, c = a - b; while (j < n && aa[j] == aa[i]) { if (aa[j] == 1) a++; else b++; if (a == b) t++; j++; } if (c > 0 && a - b < 0 || c < 0 && a - b > 0) l = max(l, j - i); } printf("%d %d\n", a, b); printf("%d\n", t); printf("%d\n", l); return 0; }

Compilation message (stderr)

preokret.c: In function 'main':
preokret.c:28:13: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   28 |   if (c > 0 && a - b < 0 || c < 0 && a - b > 0)
      |       ~~~~~~^~~~~~~~~~~~
preokret.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
preokret.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...