# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25006 | bugmenot111 | Telefoni (COCI17_telefoni) | C11 | 36 ms | 5212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |