Submission #320764

# Submission time Handle Problem Language Result Execution time Memory
320764 2020-11-09T19:22:14 Z dolphingarlic Lottery (CEOI18_lot) C++14
100 / 100
1255 ms 12260 KB
#include <bits/stdc++.h>
using namespace std;

int a[10000], pref[100][10000], ans[100][10000];
pair<int, int> k[100];

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].first);
		k[i].second = i;
	}
	sort(k, k + q);

	for (int dx = 1; dx <= n - l; dx++) {
		int diff = 0;
		for (int p = 0; p < l; p++) diff += (a[p] != a[dx + p]);
		int lb = lower_bound(k, k + q, make_pair(diff, -1)) - k;
		if (lb < q) pref[lb][0]++, pref[lb][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]);
			int lb = lower_bound(k, k + q, make_pair(diff, -1)) - k;
			if (lb < q) pref[lb][i]++, pref[lb][i + dx]++;
		}
	}
	for (int t = 0; t < q; t++) for (int i = 0; i <= n - l; i++) {
		if (t) pref[t][i] += pref[t - 1][i];
		ans[k[t].second][i] = pref[t][i];
	}
	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:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d %d", &n, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:10:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  for (int i = 0; i < n; i++) scanf("%d", a + i);
      |                              ~~~~~^~~~~~~~~~~~~
lot.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
lot.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%d", &k[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 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 1 ms 492 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 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 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 1 ms 492 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 26 ms 484 KB Output is correct
14 Correct 14 ms 748 KB Output is correct
15 Correct 9 ms 620 KB Output is correct
16 Correct 21 ms 876 KB Output is correct
17 Correct 16 ms 876 KB Output is correct
18 Correct 16 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 386 ms 484 KB Output is correct
2 Correct 293 ms 484 KB Output is correct
3 Correct 268 ms 484 KB Output is correct
4 Correct 271 ms 484 KB Output is correct
5 Correct 89 ms 364 KB Output is correct
6 Correct 237 ms 484 KB Output is correct
7 Correct 109 ms 484 KB Output is correct
8 Correct 195 ms 484 KB Output is correct
9 Correct 258 ms 484 KB Output is correct
10 Correct 260 ms 484 KB Output is correct
11 Correct 13 ms 364 KB Output is correct
12 Correct 141 ms 484 KB Output is correct
13 Correct 115 ms 364 KB Output is correct
14 Correct 112 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 386 ms 484 KB Output is correct
2 Correct 293 ms 484 KB Output is correct
3 Correct 268 ms 484 KB Output is correct
4 Correct 271 ms 484 KB Output is correct
5 Correct 89 ms 364 KB Output is correct
6 Correct 237 ms 484 KB Output is correct
7 Correct 109 ms 484 KB Output is correct
8 Correct 195 ms 484 KB Output is correct
9 Correct 258 ms 484 KB Output is correct
10 Correct 260 ms 484 KB Output is correct
11 Correct 13 ms 364 KB Output is correct
12 Correct 141 ms 484 KB Output is correct
13 Correct 115 ms 364 KB Output is correct
14 Correct 112 ms 364 KB Output is correct
15 Correct 317 ms 484 KB Output is correct
16 Correct 222 ms 484 KB Output is correct
17 Correct 277 ms 484 KB Output is correct
18 Correct 264 ms 484 KB Output is correct
19 Correct 262 ms 484 KB Output is correct
20 Correct 264 ms 484 KB Output is correct
21 Correct 264 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 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 1 ms 492 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 26 ms 484 KB Output is correct
14 Correct 14 ms 748 KB Output is correct
15 Correct 9 ms 620 KB Output is correct
16 Correct 21 ms 876 KB Output is correct
17 Correct 16 ms 876 KB Output is correct
18 Correct 16 ms 876 KB Output is correct
19 Correct 386 ms 484 KB Output is correct
20 Correct 293 ms 484 KB Output is correct
21 Correct 268 ms 484 KB Output is correct
22 Correct 271 ms 484 KB Output is correct
23 Correct 89 ms 364 KB Output is correct
24 Correct 237 ms 484 KB Output is correct
25 Correct 109 ms 484 KB Output is correct
26 Correct 195 ms 484 KB Output is correct
27 Correct 258 ms 484 KB Output is correct
28 Correct 260 ms 484 KB Output is correct
29 Correct 13 ms 364 KB Output is correct
30 Correct 141 ms 484 KB Output is correct
31 Correct 115 ms 364 KB Output is correct
32 Correct 112 ms 364 KB Output is correct
33 Correct 317 ms 484 KB Output is correct
34 Correct 222 ms 484 KB Output is correct
35 Correct 277 ms 484 KB Output is correct
36 Correct 264 ms 484 KB Output is correct
37 Correct 262 ms 484 KB Output is correct
38 Correct 264 ms 484 KB Output is correct
39 Correct 264 ms 484 KB Output is correct
40 Correct 827 ms 2784 KB Output is correct
41 Correct 15 ms 748 KB Output is correct
42 Correct 446 ms 2740 KB Output is correct
43 Correct 397 ms 2404 KB Output is correct
44 Correct 397 ms 2404 KB Output is correct
45 Correct 1255 ms 11992 KB Output is correct
46 Correct 25 ms 2404 KB Output is correct
47 Correct 831 ms 12260 KB Output is correct
48 Correct 571 ms 10616 KB Output is correct
49 Correct 569 ms 10980 KB Output is correct