# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320962 | 2020-11-10T11:01:01 Z | phathnv | Lottery (CEOI18_lot) | C++11 | 1144 ms | 12260 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "Lottery" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 1e4 + 1; const int Q = 101; int n, l, q, a[N], cnt[Q][N], res[Q][N]; ii query[Q]; void readInput(){ cin >> n >> l; for(int i = 1; i <= n; i++) cin >> a[i]; cin >> q; for(int i = 1; i <= q; i++){ cin >> query[i].X; query[i].Y = i; } } void solve(){ sort(query + 1, query + q + 1); for(int dist = 1; dist <= n - l; dist++){ int dif = 0; for(int i = 1; i <= n - dist; i++){ dif += (a[i] != a[i + dist]); if (i >= l){ int p = lower_bound(query + 1, query + q + 1, mp(dif, 0)) - query; if (p <= q){ cnt[p][i - l + 1]++; cnt[p][i + dist - l + 1]++; } dif -= (a[i - l + 1] != a[i + dist - l + 1]); } } } for(int i = 1; i <= q; i++) for(int j = 1; j <= n - l + 1; j++){ cnt[i][j] += cnt[i - 1][j]; res[query[i].Y][j] = cnt[i][j]; } for(int i = 1; i <= q; i++){ for(int j = 1; j <= n - l + 1; j++) cout << res[i][j] << ' '; cout << endl; } } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }
Compilation message
# | 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 | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 620 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 620 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 | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 620 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 25 ms | 504 KB | Output is correct |
14 | Correct | 16 ms | 748 KB | Output is correct |
15 | Correct | 9 ms | 640 KB | Output is correct |
16 | Correct | 19 ms | 876 KB | Output is correct |
17 | Correct | 18 ms | 876 KB | Output is correct |
18 | Correct | 18 ms | 876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 259 ms | 484 KB | Output is correct |
2 | Correct | 186 ms | 484 KB | Output is correct |
3 | Correct | 176 ms | 484 KB | Output is correct |
4 | Correct | 174 ms | 612 KB | Output is correct |
5 | Correct | 87 ms | 612 KB | Output is correct |
6 | Correct | 192 ms | 608 KB | Output is correct |
7 | Correct | 100 ms | 612 KB | Output is correct |
8 | Correct | 155 ms | 612 KB | Output is correct |
9 | Correct | 193 ms | 612 KB | Output is correct |
10 | Correct | 178 ms | 612 KB | Output is correct |
11 | Correct | 10 ms | 364 KB | Output is correct |
12 | Correct | 103 ms | 492 KB | Output is correct |
13 | Correct | 101 ms | 492 KB | Output is correct |
14 | Correct | 102 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 259 ms | 484 KB | Output is correct |
2 | Correct | 186 ms | 484 KB | Output is correct |
3 | Correct | 176 ms | 484 KB | Output is correct |
4 | Correct | 174 ms | 612 KB | Output is correct |
5 | Correct | 87 ms | 612 KB | Output is correct |
6 | Correct | 192 ms | 608 KB | Output is correct |
7 | Correct | 100 ms | 612 KB | Output is correct |
8 | Correct | 155 ms | 612 KB | Output is correct |
9 | Correct | 193 ms | 612 KB | Output is correct |
10 | Correct | 178 ms | 612 KB | Output is correct |
11 | Correct | 10 ms | 364 KB | Output is correct |
12 | Correct | 103 ms | 492 KB | Output is correct |
13 | Correct | 101 ms | 492 KB | Output is correct |
14 | Correct | 102 ms | 492 KB | Output is correct |
15 | Correct | 234 ms | 484 KB | Output is correct |
16 | Correct | 163 ms | 612 KB | Output is correct |
17 | Correct | 188 ms | 612 KB | Output is correct |
18 | Correct | 176 ms | 636 KB | Output is correct |
19 | Correct | 175 ms | 612 KB | Output is correct |
20 | Correct | 190 ms | 740 KB | Output is correct |
21 | Correct | 175 ms | 612 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 | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 2 ms | 620 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 620 KB | Output is correct |
13 | Correct | 25 ms | 504 KB | Output is correct |
14 | Correct | 16 ms | 748 KB | Output is correct |
15 | Correct | 9 ms | 640 KB | Output is correct |
16 | Correct | 19 ms | 876 KB | Output is correct |
17 | Correct | 18 ms | 876 KB | Output is correct |
18 | Correct | 18 ms | 876 KB | Output is correct |
19 | Correct | 259 ms | 484 KB | Output is correct |
20 | Correct | 186 ms | 484 KB | Output is correct |
21 | Correct | 176 ms | 484 KB | Output is correct |
22 | Correct | 174 ms | 612 KB | Output is correct |
23 | Correct | 87 ms | 612 KB | Output is correct |
24 | Correct | 192 ms | 608 KB | Output is correct |
25 | Correct | 100 ms | 612 KB | Output is correct |
26 | Correct | 155 ms | 612 KB | Output is correct |
27 | Correct | 193 ms | 612 KB | Output is correct |
28 | Correct | 178 ms | 612 KB | Output is correct |
29 | Correct | 10 ms | 364 KB | Output is correct |
30 | Correct | 103 ms | 492 KB | Output is correct |
31 | Correct | 101 ms | 492 KB | Output is correct |
32 | Correct | 102 ms | 492 KB | Output is correct |
33 | Correct | 234 ms | 484 KB | Output is correct |
34 | Correct | 163 ms | 612 KB | Output is correct |
35 | Correct | 188 ms | 612 KB | Output is correct |
36 | Correct | 176 ms | 636 KB | Output is correct |
37 | Correct | 175 ms | 612 KB | Output is correct |
38 | Correct | 190 ms | 740 KB | Output is correct |
39 | Correct | 175 ms | 612 KB | Output is correct |
40 | Correct | 743 ms | 2844 KB | Output is correct |
41 | Correct | 20 ms | 868 KB | Output is correct |
42 | Correct | 383 ms | 2788 KB | Output is correct |
43 | Correct | 323 ms | 2536 KB | Output is correct |
44 | Correct | 323 ms | 2660 KB | Output is correct |
45 | Correct | 1144 ms | 12004 KB | Output is correct |
46 | Correct | 32 ms | 2404 KB | Output is correct |
47 | Correct | 954 ms | 12260 KB | Output is correct |
48 | Correct | 506 ms | 10468 KB | Output is correct |
49 | Correct | 519 ms | 11108 KB | Output is correct |