Submission #528251

#TimeUsernameProblemLanguageResultExecution timeMemory
528251rainboyIzbori (COCI22_izbori)C11
0 / 110
13 ms2420 KiB
#include <stdio.h> #define N 200000 #define SMALL 2000 int main() { static int aa[N], kk[N + 1], cc[N * 2 + 1]; int n, i, l, r, a, k, k_; long long cnt; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); if (n <= SMALL && 0) { cnt = 0; for (l = 0; l < n; l++) { a = 0, k = 0; for (r = l; r < n; r++) { if (k == 0) a = aa[r], k++; else if (a == aa[r]) k++; else k--; k_ = 0; for (i = l; i <= r; i++) if (aa[i] == a) k_++; else k_--; if (k_ > 0) cnt++; } } } else { k = 0; for (i = 0; i < n; i++) kk[i + 1] = kk[i] + (aa[i] == 1 ? 1 : -1); for (i = 0; i <= n; i++) cc[n + kk[i]]++; cnt = (long long) n * (n + 1) / 2; for (k = -n; k <= n; k++) cnt -= (long long) cc[k] * (cc[k] - 1) / 2; } printf("%lld\n", cnt); return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...