# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522129 | 2022-02-03T21:59:51 Z | LucaDantas | Lottery (CEOI18_lot) | C++17 | 1338 ms | 12580 KB |
#include <cstdio> #include <vector> #include <algorithm> constexpr int maxn = 1e4+10, maxq = 105; int a[maxn], dist[maxn<<1], qtd[maxn], n; void add(int x) { for(int i = 0; i < n; i++) if(a[i] != a[x]) ++dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio } void rmv(int x) { for(int i = 0; i < n; i++) if(a[i] != a[x]) --dist[i - x + maxn]; // adiciono o maxn pra normalizar no meio } int prox[maxn], ans[maxn][maxq], ans2[maxn][maxq]; int main() { int l; scanf("%d %d", &n, &l); for(int i = 0; i < n; i++) scanf("%d", a+i); for(int i = 0; i < l; i++) add(i); int q; scanf("%d", &q); std::vector<std::pair<int,int>> td(q); for(int i = 0, x; i < q; i++) scanf("%d", &x), td[i] = {x, i}; std::sort(td.begin(), td.end()); for(int i = 0; i <= l; i++) prox[i] = lower_bound(td.begin(), td.end(), std::pair<int,int>(i, 0)) - td.begin(); for(int i = 0; i < n-l+1; i++) { for(int j = maxn-i; j < maxn + n-l+1-i; j++) if(j != maxn) ans[i][prox[dist[j]]]++; for(int j = 1; j < q; j++) ans[i][j] += ans[i][j-1]; for(int j = 0; j < q; j++) ans2[i][td[j].second] = ans[i][j]; rmv(i); add(i+l); } for(int j = 0; j < q; j++) { for(int i = 0; i < n-l+1; i++) printf("%d ", ans2[i][j]); puts(""); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 33 ms | 1988 KB | Output is correct |
14 | Correct | 16 ms | 1484 KB | Output is correct |
15 | Correct | 16 ms | 1484 KB | Output is correct |
16 | Correct | 25 ms | 1800 KB | Output is correct |
17 | Correct | 23 ms | 1680 KB | Output is correct |
18 | Correct | 24 ms | 1720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1282 ms | 8604 KB | Output is correct |
2 | Correct | 1277 ms | 8712 KB | Output is correct |
3 | Correct | 785 ms | 8764 KB | Output is correct |
4 | Correct | 634 ms | 8384 KB | Output is correct |
5 | Correct | 264 ms | 4420 KB | Output is correct |
6 | Correct | 575 ms | 8212 KB | Output is correct |
7 | Correct | 229 ms | 4548 KB | Output is correct |
8 | Correct | 366 ms | 6064 KB | Output is correct |
9 | Correct | 610 ms | 8316 KB | Output is correct |
10 | Correct | 634 ms | 8412 KB | Output is correct |
11 | Correct | 39 ms | 1860 KB | Output is correct |
12 | Correct | 386 ms | 6096 KB | Output is correct |
13 | Correct | 322 ms | 5172 KB | Output is correct |
14 | Correct | 334 ms | 5224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1282 ms | 8604 KB | Output is correct |
2 | Correct | 1277 ms | 8712 KB | Output is correct |
3 | Correct | 785 ms | 8764 KB | Output is correct |
4 | Correct | 634 ms | 8384 KB | Output is correct |
5 | Correct | 264 ms | 4420 KB | Output is correct |
6 | Correct | 575 ms | 8212 KB | Output is correct |
7 | Correct | 229 ms | 4548 KB | Output is correct |
8 | Correct | 366 ms | 6064 KB | Output is correct |
9 | Correct | 610 ms | 8316 KB | Output is correct |
10 | Correct | 634 ms | 8412 KB | Output is correct |
11 | Correct | 39 ms | 1860 KB | Output is correct |
12 | Correct | 386 ms | 6096 KB | Output is correct |
13 | Correct | 322 ms | 5172 KB | Output is correct |
14 | Correct | 334 ms | 5224 KB | Output is correct |
15 | Correct | 753 ms | 8292 KB | Output is correct |
16 | Correct | 574 ms | 7784 KB | Output is correct |
17 | Correct | 667 ms | 8572 KB | Output is correct |
18 | Correct | 636 ms | 8628 KB | Output is correct |
19 | Correct | 635 ms | 8528 KB | Output is correct |
20 | Correct | 640 ms | 8464 KB | Output is correct |
21 | Correct | 640 ms | 8644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 33 ms | 1988 KB | Output is correct |
14 | Correct | 16 ms | 1484 KB | Output is correct |
15 | Correct | 16 ms | 1484 KB | Output is correct |
16 | Correct | 25 ms | 1800 KB | Output is correct |
17 | Correct | 23 ms | 1680 KB | Output is correct |
18 | Correct | 24 ms | 1720 KB | Output is correct |
19 | Correct | 1282 ms | 8604 KB | Output is correct |
20 | Correct | 1277 ms | 8712 KB | Output is correct |
21 | Correct | 785 ms | 8764 KB | Output is correct |
22 | Correct | 634 ms | 8384 KB | Output is correct |
23 | Correct | 264 ms | 4420 KB | Output is correct |
24 | Correct | 575 ms | 8212 KB | Output is correct |
25 | Correct | 229 ms | 4548 KB | Output is correct |
26 | Correct | 366 ms | 6064 KB | Output is correct |
27 | Correct | 610 ms | 8316 KB | Output is correct |
28 | Correct | 634 ms | 8412 KB | Output is correct |
29 | Correct | 39 ms | 1860 KB | Output is correct |
30 | Correct | 386 ms | 6096 KB | Output is correct |
31 | Correct | 322 ms | 5172 KB | Output is correct |
32 | Correct | 334 ms | 5224 KB | Output is correct |
33 | Correct | 753 ms | 8292 KB | Output is correct |
34 | Correct | 574 ms | 7784 KB | Output is correct |
35 | Correct | 667 ms | 8572 KB | Output is correct |
36 | Correct | 636 ms | 8628 KB | Output is correct |
37 | Correct | 635 ms | 8528 KB | Output is correct |
38 | Correct | 640 ms | 8464 KB | Output is correct |
39 | Correct | 640 ms | 8644 KB | Output is correct |
40 | Correct | 1269 ms | 9232 KB | Output is correct |
41 | Correct | 97 ms | 1308 KB | Output is correct |
42 | Correct | 642 ms | 9272 KB | Output is correct |
43 | Correct | 622 ms | 8628 KB | Output is correct |
44 | Correct | 614 ms | 8756 KB | Output is correct |
45 | Correct | 1338 ms | 12384 KB | Output is correct |
46 | Correct | 98 ms | 1616 KB | Output is correct |
47 | Correct | 716 ms | 12580 KB | Output is correct |
48 | Correct | 670 ms | 10408 KB | Output is correct |
49 | Correct | 672 ms | 11256 KB | Output is correct |