# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528251 | 2022-02-19T18:23:45 Z | rainboy | Izbori (COCI22_izbori) | C | 13 ms | 2420 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 2420 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |