Submission #320761

# Submission time Handle Problem Language Result Execution time Memory
320761 2020-11-09T19:06:19 Z dolphingarlic Lottery (CEOI18_lot) C++14
80 / 100
3000 ms 1656 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 - dx; i++) {
				int j = i + dx;
				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);
      |   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 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 0 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 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 4 ms 380 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 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 0 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 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 4 ms 380 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 24 ms 364 KB Output is correct
14 Correct 29 ms 364 KB Output is correct
15 Correct 17 ms 492 KB Output is correct
16 Correct 47 ms 484 KB Output is correct
17 Correct 44 ms 492 KB Output is correct
18 Correct 41 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 492 KB Output is correct
2 Correct 78 ms 484 KB Output is correct
3 Correct 79 ms 484 KB Output is correct
4 Correct 71 ms 484 KB Output is correct
5 Correct 37 ms 364 KB Output is correct
6 Correct 65 ms 484 KB Output is correct
7 Correct 42 ms 484 KB Output is correct
8 Correct 62 ms 484 KB Output is correct
9 Correct 70 ms 484 KB Output is correct
10 Correct 68 ms 484 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 48 ms 476 KB Output is correct
13 Correct 45 ms 364 KB Output is correct
14 Correct 43 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 147 ms 492 KB Output is correct
2 Correct 78 ms 484 KB Output is correct
3 Correct 79 ms 484 KB Output is correct
4 Correct 71 ms 484 KB Output is correct
5 Correct 37 ms 364 KB Output is correct
6 Correct 65 ms 484 KB Output is correct
7 Correct 42 ms 484 KB Output is correct
8 Correct 62 ms 484 KB Output is correct
9 Correct 70 ms 484 KB Output is correct
10 Correct 68 ms 484 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 48 ms 476 KB Output is correct
13 Correct 45 ms 364 KB Output is correct
14 Correct 43 ms 364 KB Output is correct
15 Correct 82 ms 484 KB Output is correct
16 Correct 66 ms 484 KB Output is correct
17 Correct 75 ms 484 KB Output is correct
18 Correct 68 ms 488 KB Output is correct
19 Correct 69 ms 484 KB Output is correct
20 Correct 69 ms 492 KB Output is correct
21 Correct 68 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 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 0 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 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 4 ms 380 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 24 ms 364 KB Output is correct
14 Correct 29 ms 364 KB Output is correct
15 Correct 17 ms 492 KB Output is correct
16 Correct 47 ms 484 KB Output is correct
17 Correct 44 ms 492 KB Output is correct
18 Correct 41 ms 364 KB Output is correct
19 Correct 147 ms 492 KB Output is correct
20 Correct 78 ms 484 KB Output is correct
21 Correct 79 ms 484 KB Output is correct
22 Correct 71 ms 484 KB Output is correct
23 Correct 37 ms 364 KB Output is correct
24 Correct 65 ms 484 KB Output is correct
25 Correct 42 ms 484 KB Output is correct
26 Correct 62 ms 484 KB Output is correct
27 Correct 70 ms 484 KB Output is correct
28 Correct 68 ms 484 KB Output is correct
29 Correct 5 ms 364 KB Output is correct
30 Correct 48 ms 476 KB Output is correct
31 Correct 45 ms 364 KB Output is correct
32 Correct 43 ms 364 KB Output is correct
33 Correct 82 ms 484 KB Output is correct
34 Correct 66 ms 484 KB Output is correct
35 Correct 75 ms 484 KB Output is correct
36 Correct 68 ms 488 KB Output is correct
37 Correct 69 ms 484 KB Output is correct
38 Correct 69 ms 492 KB Output is correct
39 Correct 68 ms 484 KB Output is correct
40 Correct 1638 ms 1436 KB Output is correct
41 Correct 24 ms 492 KB Output is correct
42 Correct 1374 ms 1508 KB Output is correct
43 Correct 1261 ms 1124 KB Output is correct
44 Correct 1254 ms 1276 KB Output is correct
45 Execution timed out 3036 ms 1656 KB Time limit exceeded
46 Halted 0 ms 0 KB -