# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112954 | 2019-05-22T19:51:13 Z | luciocf | Lottery (CEOI18_lot) | C++14 | 688 ms | 8568 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; const int maxn = 1e4+10; const int maxq = 110; typedef pair<int, int> pii; int a[maxn]; int first[maxn]; int ans[maxn][maxq]; pii query[maxq]; int main(void) { int n, l; scanf("%d %d", &n, &l); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); int q; scanf("%d", &q); for (int i = 1; i <= q; i++) { scanf("%d", &query[i].ff); query[i].ss = i; } sort(query+1, query+q+1); for (int i = 0; i <= l; i++) { first[i] = q+1; for (int j = 1; j <= q; j++) { if (query[j].ff >= i) { first[i] = query[j].ss; break; } } } for (int i = 1; i+l-1 <= n; i++) { int at = 0; for (int j = 1; j <= l; j++) if (a[i+j-1] != a[j]) at++; if (i != 1) { ans[1][first[at]]++; ans[i][first[at]]++; } for (int j = 2; j+l-1 <= n; j++) { int pos = i+j-1; if (pos+l-1 > n) break; if (a[j-1] != a[pos-1]) at--; if (a[j+l-1] != a[pos+l-1]) at++; if (j != pos) { ans[j][first[at]]++; ans[pos][first[at]]++; } } } for (int i = 1; i <= q; i++) for (int j = 1; j <= n; j++) ans[j][query[i].ss] += ans[j][query[i-1].ss]; for (int i = 1; i <= q; i++) { for (int j = 1; j <= n-l+1; j++) { if (j == n-l+1) printf("%d\n", ans[j][i]); else printf("%d ", ans[j][i]); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 15 ms | 1280 KB | Output is correct |
14 | Correct | 9 ms | 1280 KB | Output is correct |
15 | Correct | 9 ms | 1280 KB | Output is correct |
16 | Correct | 13 ms | 1280 KB | Output is correct |
17 | Correct | 12 ms | 1280 KB | Output is correct |
18 | Correct | 13 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 478 ms | 4736 KB | Output is correct |
2 | Correct | 607 ms | 4756 KB | Output is correct |
3 | Correct | 398 ms | 4736 KB | Output is correct |
4 | Correct | 377 ms | 4728 KB | Output is correct |
5 | Correct | 104 ms | 4856 KB | Output is correct |
6 | Correct | 358 ms | 4776 KB | Output is correct |
7 | Correct | 102 ms | 4856 KB | Output is correct |
8 | Correct | 196 ms | 4856 KB | Output is correct |
9 | Correct | 345 ms | 4784 KB | Output is correct |
10 | Correct | 362 ms | 4968 KB | Output is correct |
11 | Correct | 17 ms | 1664 KB | Output is correct |
12 | Correct | 191 ms | 4444 KB | Output is correct |
13 | Correct | 159 ms | 4828 KB | Output is correct |
14 | Correct | 159 ms | 4828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 478 ms | 4736 KB | Output is correct |
2 | Correct | 607 ms | 4756 KB | Output is correct |
3 | Correct | 398 ms | 4736 KB | Output is correct |
4 | Correct | 377 ms | 4728 KB | Output is correct |
5 | Correct | 104 ms | 4856 KB | Output is correct |
6 | Correct | 358 ms | 4776 KB | Output is correct |
7 | Correct | 102 ms | 4856 KB | Output is correct |
8 | Correct | 196 ms | 4856 KB | Output is correct |
9 | Correct | 345 ms | 4784 KB | Output is correct |
10 | Correct | 362 ms | 4968 KB | Output is correct |
11 | Correct | 17 ms | 1664 KB | Output is correct |
12 | Correct | 191 ms | 4444 KB | Output is correct |
13 | Correct | 159 ms | 4828 KB | Output is correct |
14 | Correct | 159 ms | 4828 KB | Output is correct |
15 | Correct | 390 ms | 4712 KB | Output is correct |
16 | Correct | 306 ms | 4728 KB | Output is correct |
17 | Correct | 369 ms | 4856 KB | Output is correct |
18 | Correct | 364 ms | 4764 KB | Output is correct |
19 | Correct | 358 ms | 4856 KB | Output is correct |
20 | Correct | 362 ms | 4864 KB | Output is correct |
21 | Correct | 359 ms | 4856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 15 ms | 1280 KB | Output is correct |
14 | Correct | 9 ms | 1280 KB | Output is correct |
15 | Correct | 9 ms | 1280 KB | Output is correct |
16 | Correct | 13 ms | 1280 KB | Output is correct |
17 | Correct | 12 ms | 1280 KB | Output is correct |
18 | Correct | 13 ms | 1280 KB | Output is correct |
19 | Correct | 478 ms | 4736 KB | Output is correct |
20 | Correct | 607 ms | 4756 KB | Output is correct |
21 | Correct | 398 ms | 4736 KB | Output is correct |
22 | Correct | 377 ms | 4728 KB | Output is correct |
23 | Correct | 104 ms | 4856 KB | Output is correct |
24 | Correct | 358 ms | 4776 KB | Output is correct |
25 | Correct | 102 ms | 4856 KB | Output is correct |
26 | Correct | 196 ms | 4856 KB | Output is correct |
27 | Correct | 345 ms | 4784 KB | Output is correct |
28 | Correct | 362 ms | 4968 KB | Output is correct |
29 | Correct | 17 ms | 1664 KB | Output is correct |
30 | Correct | 191 ms | 4444 KB | Output is correct |
31 | Correct | 159 ms | 4828 KB | Output is correct |
32 | Correct | 159 ms | 4828 KB | Output is correct |
33 | Correct | 390 ms | 4712 KB | Output is correct |
34 | Correct | 306 ms | 4728 KB | Output is correct |
35 | Correct | 369 ms | 4856 KB | Output is correct |
36 | Correct | 364 ms | 4764 KB | Output is correct |
37 | Correct | 358 ms | 4856 KB | Output is correct |
38 | Correct | 362 ms | 4864 KB | Output is correct |
39 | Correct | 359 ms | 4856 KB | Output is correct |
40 | Correct | 657 ms | 5488 KB | Output is correct |
41 | Correct | 18 ms | 4864 KB | Output is correct |
42 | Correct | 378 ms | 5496 KB | Output is correct |
43 | Correct | 351 ms | 5240 KB | Output is correct |
44 | Correct | 352 ms | 5292 KB | Output is correct |
45 | Correct | 688 ms | 8432 KB | Output is correct |
46 | Correct | 32 ms | 5112 KB | Output is correct |
47 | Correct | 452 ms | 8568 KB | Output is correct |
48 | Correct | 414 ms | 6904 KB | Output is correct |
49 | Correct | 414 ms | 7544 KB | Output is correct |