Submission #320762

# Submission time Handle Problem Language Result Execution time Memory
320762 2020-11-09T19:13:05 Z dolphingarlic Lottery (CEOI18_lot) C++14
80 / 100
3000 ms 3832 KB
#include <bits/stdc++.h>
using namespace std;

int a[10000], k[100], ans[100][10000];

int main() {
	int n, l, q;
	scanf("%d %d", &n, &l);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	scanf("%d", &q);
	for (int i = 0; i < q; i++) scanf("%d", k + i);

	for (int dx = 1; dx <= n - l; dx++) {
		int diff = 0;
		for (int p = 0; p < l; p++) diff += (a[p] != a[dx + p]);
		for (int t = 0; t < q; t++) if (diff <= k[t]) ans[t][0]++, ans[t][dx]++;
		for (int i = 1; i <= n - l - dx; i++) {
			diff += (a[i + l - 1] != a[i + dx + l - 1]) - (a[i - 1] != a[i + dx - 1]);
			for (int t = 0; t < q; t++) if (diff <= k[t]) ans[t][i]++, ans[t][i + dx]++;
		}
	}
	for (int t = 0; t < q; t++) {
		for (int i = 0; i <= n - l; i++) printf("%d ", ans[t][i]);
		printf("\n");
	}
}

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:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
lot.cpp:11:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  for (int i = 0; i < q; i++) scanf("%d", k + i);
      |                              ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory 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 1 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 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory 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 1 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 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 18 ms 492 KB Output is correct
14 Correct 23 ms 364 KB Output is correct
15 Correct 20 ms 492 KB Output is correct
16 Correct 50 ms 740 KB Output is correct
17 Correct 44 ms 612 KB Output is correct
18 Correct 45 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 484 KB Output is correct
2 Correct 121 ms 484 KB Output is correct
3 Correct 109 ms 484 KB Output is correct
4 Correct 122 ms 484 KB Output is correct
5 Correct 51 ms 364 KB Output is correct
6 Correct 99 ms 384 KB Output is correct
7 Correct 52 ms 364 KB Output is correct
8 Correct 78 ms 364 KB Output is correct
9 Correct 105 ms 484 KB Output is correct
10 Correct 107 ms 484 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 65 ms 364 KB Output is correct
13 Correct 59 ms 364 KB Output is correct
14 Correct 59 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 484 KB Output is correct
2 Correct 121 ms 484 KB Output is correct
3 Correct 109 ms 484 KB Output is correct
4 Correct 122 ms 484 KB Output is correct
5 Correct 51 ms 364 KB Output is correct
6 Correct 99 ms 384 KB Output is correct
7 Correct 52 ms 364 KB Output is correct
8 Correct 78 ms 364 KB Output is correct
9 Correct 105 ms 484 KB Output is correct
10 Correct 107 ms 484 KB Output is correct
11 Correct 7 ms 364 KB Output is correct
12 Correct 65 ms 364 KB Output is correct
13 Correct 59 ms 364 KB Output is correct
14 Correct 59 ms 364 KB Output is correct
15 Correct 115 ms 488 KB Output is correct
16 Correct 95 ms 484 KB Output is correct
17 Correct 118 ms 484 KB Output is correct
18 Correct 107 ms 364 KB Output is correct
19 Correct 108 ms 484 KB Output is correct
20 Correct 108 ms 484 KB Output is correct
21 Correct 107 ms 364 KB Output is correct
# Verdict Execution time Memory 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 1 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 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 492 KB Output is correct
13 Correct 18 ms 492 KB Output is correct
14 Correct 23 ms 364 KB Output is correct
15 Correct 20 ms 492 KB Output is correct
16 Correct 50 ms 740 KB Output is correct
17 Correct 44 ms 612 KB Output is correct
18 Correct 45 ms 492 KB Output is correct
19 Correct 178 ms 484 KB Output is correct
20 Correct 121 ms 484 KB Output is correct
21 Correct 109 ms 484 KB Output is correct
22 Correct 122 ms 484 KB Output is correct
23 Correct 51 ms 364 KB Output is correct
24 Correct 99 ms 384 KB Output is correct
25 Correct 52 ms 364 KB Output is correct
26 Correct 78 ms 364 KB Output is correct
27 Correct 105 ms 484 KB Output is correct
28 Correct 107 ms 484 KB Output is correct
29 Correct 7 ms 364 KB Output is correct
30 Correct 65 ms 364 KB Output is correct
31 Correct 59 ms 364 KB Output is correct
32 Correct 59 ms 364 KB Output is correct
33 Correct 115 ms 488 KB Output is correct
34 Correct 95 ms 484 KB Output is correct
35 Correct 118 ms 484 KB Output is correct
36 Correct 107 ms 364 KB Output is correct
37 Correct 108 ms 484 KB Output is correct
38 Correct 108 ms 484 KB Output is correct
39 Correct 107 ms 364 KB Output is correct
40 Correct 1170 ms 1764 KB Output is correct
41 Correct 25 ms 620 KB Output is correct
42 Correct 1470 ms 2020 KB Output is correct
43 Correct 1331 ms 1552 KB Output is correct
44 Correct 1341 ms 1632 KB Output is correct
45 Execution timed out 3048 ms 3832 KB Time limit exceeded
46 Halted 0 ms 0 KB -