답안 #320760

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320760 2020-11-09T19:05:26 Z dolphingarlic Lottery (CEOI18_lot) C++14
80 / 100
3000 ms 1252 KB
#include <bits/stdc++.h>
using namespace std;

int a[10000], base[10000], ans[10000];

int main() {
	int n, l, q;
	scanf("%d %d", &n, &l);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	for (int dx = 1; dx <= n - l; dx++) {
		for (int p = 0; p < l; p++) base[dx] += (a[p] != a[dx + p]);
	}
	scanf("%d", &q);
	while (q--) {
		int k;
		scanf("%d", &k);
		for (int dx = 1; dx <= n - l; dx++) {
			int diff = base[dx];
			if (diff <= k) ans[0]++, ans[dx]++;
			for (int i = 1; i <= n - l; i++) {
				int j = i + dx;
				if (j < 0 || j > n - l) continue;
				diff += (a[i + l - 1] != a[j + l - 1]) - (a[i - 1] != a[j - 1]);
				if (diff <= k) ans[i]++, ans[j]++;
			}
		}
		for (int i = 0; i <= n - l; i++) printf("%d ", ans[i]);
		printf("\n");
		fill(ans, ans + n - l + 1, 0);
	}
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |  scanf("%d %d", &n, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:9:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  for (int i = 0; i < n; i++) scanf("%d", a + i);
      |                              ~~~~~^~~~~~~~~~~~~
lot.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
lot.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 38 ms 364 KB Output is correct
14 Correct 63 ms 364 KB Output is correct
15 Correct 34 ms 364 KB Output is correct
16 Correct 108 ms 480 KB Output is correct
17 Correct 93 ms 364 KB Output is correct
18 Correct 94 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 484 KB Output is correct
2 Correct 173 ms 632 KB Output is correct
3 Correct 161 ms 484 KB Output is correct
4 Correct 156 ms 484 KB Output is correct
5 Correct 60 ms 364 KB Output is correct
6 Correct 144 ms 484 KB Output is correct
7 Correct 63 ms 484 KB Output is correct
8 Correct 102 ms 488 KB Output is correct
9 Correct 154 ms 484 KB Output is correct
10 Correct 156 ms 492 KB Output is correct
11 Correct 9 ms 364 KB Output is correct
12 Correct 89 ms 364 KB Output is correct
13 Correct 75 ms 364 KB Output is correct
14 Correct 76 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 484 KB Output is correct
2 Correct 173 ms 632 KB Output is correct
3 Correct 161 ms 484 KB Output is correct
4 Correct 156 ms 484 KB Output is correct
5 Correct 60 ms 364 KB Output is correct
6 Correct 144 ms 484 KB Output is correct
7 Correct 63 ms 484 KB Output is correct
8 Correct 102 ms 488 KB Output is correct
9 Correct 154 ms 484 KB Output is correct
10 Correct 156 ms 492 KB Output is correct
11 Correct 9 ms 364 KB Output is correct
12 Correct 89 ms 364 KB Output is correct
13 Correct 75 ms 364 KB Output is correct
14 Correct 76 ms 364 KB Output is correct
15 Correct 167 ms 484 KB Output is correct
16 Correct 139 ms 484 KB Output is correct
17 Correct 173 ms 484 KB Output is correct
18 Correct 158 ms 484 KB Output is correct
19 Correct 158 ms 740 KB Output is correct
20 Correct 159 ms 484 KB Output is correct
21 Correct 160 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 4 ms 364 KB Output is correct
11 Correct 4 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 38 ms 364 KB Output is correct
14 Correct 63 ms 364 KB Output is correct
15 Correct 34 ms 364 KB Output is correct
16 Correct 108 ms 480 KB Output is correct
17 Correct 93 ms 364 KB Output is correct
18 Correct 94 ms 620 KB Output is correct
19 Correct 231 ms 484 KB Output is correct
20 Correct 173 ms 632 KB Output is correct
21 Correct 161 ms 484 KB Output is correct
22 Correct 156 ms 484 KB Output is correct
23 Correct 60 ms 364 KB Output is correct
24 Correct 144 ms 484 KB Output is correct
25 Correct 63 ms 484 KB Output is correct
26 Correct 102 ms 488 KB Output is correct
27 Correct 154 ms 484 KB Output is correct
28 Correct 156 ms 492 KB Output is correct
29 Correct 9 ms 364 KB Output is correct
30 Correct 89 ms 364 KB Output is correct
31 Correct 75 ms 364 KB Output is correct
32 Correct 76 ms 364 KB Output is correct
33 Correct 167 ms 484 KB Output is correct
34 Correct 139 ms 484 KB Output is correct
35 Correct 173 ms 484 KB Output is correct
36 Correct 158 ms 484 KB Output is correct
37 Correct 158 ms 740 KB Output is correct
38 Correct 159 ms 484 KB Output is correct
39 Correct 160 ms 484 KB Output is correct
40 Execution timed out 3072 ms 1252 KB Time limit exceeded
41 Halted 0 ms 0 KB -