Submission #25006

#TimeUsernameProblemLanguageResultExecution timeMemory
25006bugmenot111Telefoni (COCI17_telefoni)C11
24 / 80
36 ms5212 KiB
#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)

telefoni.c: In function 'main':
telefoni.c:21:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &d);
  ^
telefoni.c:22:29: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%d", &t[i + n]);
                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...