# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25006 | 2017-06-20T00:41:28 Z | bugmenot111 | Telefoni (COCI17_telefoni) | C | 36 ms | 5212 KB |
#include <stdio.h> #define MAXN 1<<19 int t[2 * MAXN]; int n; void build(void) { for(int i = n - 1; i > 0; i--) t[i] = t[i << 1] + t[i << 1 | 1]; } int query(int l, int r) { int s = 0; for(l += n, r += n; l < r; l >>= 1,r >>= 1) { if(l & 1) s += t[l++]; if(r & 1) s += t[--r]; } return s; } void modify(int p, int value) { for(t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = t[p] + t[p ^ 1]; } int main(void) { int d, cnt = 0; scanf("%d%d", &n, &d); for(int i = 0; i < n; i++) scanf("%d", &t[i + n]); build(); for(int i = d; i < n; i++) if(query(i - d, i) == 0) modify(i, 1), cnt++; printf("%d\n", cnt); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5212 KB | Output is correct |
2 | Correct | 0 ms | 5212 KB | Output is correct |
3 | Correct | 0 ms | 5212 KB | Output is correct |
4 | Incorrect | 0 ms | 5212 KB | Output isn't correct |
5 | Incorrect | 0 ms | 5212 KB | Output isn't correct |
6 | Incorrect | 0 ms | 5212 KB | Output isn't correct |
7 | Incorrect | 0 ms | 5212 KB | Output isn't correct |
8 | Incorrect | 36 ms | 5212 KB | Output isn't correct |
9 | Incorrect | 26 ms | 5212 KB | Output isn't correct |
10 | Incorrect | 36 ms | 5212 KB | Output isn't correct |