답안 #25007

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25007 2017-06-20T00:41:59 Z bugmenot111 Telefoni (COCI17_telefoni) C
0 / 80
39 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 + 1) == 0) modify(i, 1), cnt++;
	printf("%d\n", cnt);
	return 0;
}

Compilation message

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]);
                             ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5212 KB Output isn't correct
2 Incorrect 0 ms 5212 KB Output isn't correct
3 Incorrect 0 ms 5212 KB Output isn't 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 39 ms 5212 KB Output isn't correct
9 Incorrect 33 ms 5212 KB Output isn't correct
10 Incorrect 36 ms 5212 KB Output isn't correct