# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1086371 |
2024-09-10T11:07:42 Z |
juicy |
Lottery (CEOI18_lot) |
C++17 |
|
355 ms |
8500 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 10005, Q = 105;
int n, l, q;
int a[N], qu[Q], b[Q], id[N], pf[N], res[N][Q];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> l; --l;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
cin >> q;
for (int i = 1; i <= q; ++i) {
cin >> qu[i];
b[i] = qu[i];
}
sort(b + 1, b + q + 1);
for (int i = 1, j = 0; i <= n; ++i) {
while (j <= q && b[j] < i) {
++j;
}
id[i] = j;
}
for (int d = 1; d <= n; ++d) {
for (int i = 1; i + d <= n; ++i) {
pf[i] = pf[i - 1] + (a[i] != a[i + d]);
}
for (int i = 1; i + d + l <= n; ++i) {
int k = pf[i + l] - pf[i - 1];
++res[i][id[k]];
++res[i + d][id[k]];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= q; ++j) {
res[i][j] += res[i][j - 1];
}
}
for (int i = 1; i <= q; ++i) {
for (int j = 1; j + l <= n; ++j) {
cout << res[j][id[qu[i]]] << " ";
}
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
11 ms |
1368 KB |
Output is correct |
14 |
Correct |
9 ms |
1372 KB |
Output is correct |
15 |
Correct |
8 ms |
1328 KB |
Output is correct |
16 |
Correct |
11 ms |
1372 KB |
Output is correct |
17 |
Correct |
11 ms |
1372 KB |
Output is correct |
18 |
Correct |
12 ms |
1204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
292 ms |
4700 KB |
Output is correct |
2 |
Correct |
294 ms |
4704 KB |
Output is correct |
3 |
Correct |
293 ms |
4696 KB |
Output is correct |
4 |
Correct |
281 ms |
4700 KB |
Output is correct |
5 |
Correct |
165 ms |
4524 KB |
Output is correct |
6 |
Correct |
266 ms |
4752 KB |
Output is correct |
7 |
Correct |
165 ms |
4688 KB |
Output is correct |
8 |
Correct |
204 ms |
4692 KB |
Output is correct |
9 |
Correct |
276 ms |
4624 KB |
Output is correct |
10 |
Correct |
288 ms |
4700 KB |
Output is correct |
11 |
Correct |
17 ms |
1624 KB |
Output is correct |
12 |
Correct |
178 ms |
4180 KB |
Output is correct |
13 |
Correct |
180 ms |
4688 KB |
Output is correct |
14 |
Correct |
181 ms |
4688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
292 ms |
4700 KB |
Output is correct |
2 |
Correct |
294 ms |
4704 KB |
Output is correct |
3 |
Correct |
293 ms |
4696 KB |
Output is correct |
4 |
Correct |
281 ms |
4700 KB |
Output is correct |
5 |
Correct |
165 ms |
4524 KB |
Output is correct |
6 |
Correct |
266 ms |
4752 KB |
Output is correct |
7 |
Correct |
165 ms |
4688 KB |
Output is correct |
8 |
Correct |
204 ms |
4692 KB |
Output is correct |
9 |
Correct |
276 ms |
4624 KB |
Output is correct |
10 |
Correct |
288 ms |
4700 KB |
Output is correct |
11 |
Correct |
17 ms |
1624 KB |
Output is correct |
12 |
Correct |
178 ms |
4180 KB |
Output is correct |
13 |
Correct |
180 ms |
4688 KB |
Output is correct |
14 |
Correct |
181 ms |
4688 KB |
Output is correct |
15 |
Correct |
288 ms |
4548 KB |
Output is correct |
16 |
Correct |
258 ms |
4688 KB |
Output is correct |
17 |
Correct |
293 ms |
4700 KB |
Output is correct |
18 |
Correct |
292 ms |
4696 KB |
Output is correct |
19 |
Correct |
289 ms |
4724 KB |
Output is correct |
20 |
Correct |
283 ms |
4700 KB |
Output is correct |
21 |
Correct |
288 ms |
4720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
11 ms |
1368 KB |
Output is correct |
14 |
Correct |
9 ms |
1372 KB |
Output is correct |
15 |
Correct |
8 ms |
1328 KB |
Output is correct |
16 |
Correct |
11 ms |
1372 KB |
Output is correct |
17 |
Correct |
11 ms |
1372 KB |
Output is correct |
18 |
Correct |
12 ms |
1204 KB |
Output is correct |
19 |
Correct |
292 ms |
4700 KB |
Output is correct |
20 |
Correct |
294 ms |
4704 KB |
Output is correct |
21 |
Correct |
293 ms |
4696 KB |
Output is correct |
22 |
Correct |
281 ms |
4700 KB |
Output is correct |
23 |
Correct |
165 ms |
4524 KB |
Output is correct |
24 |
Correct |
266 ms |
4752 KB |
Output is correct |
25 |
Correct |
165 ms |
4688 KB |
Output is correct |
26 |
Correct |
204 ms |
4692 KB |
Output is correct |
27 |
Correct |
276 ms |
4624 KB |
Output is correct |
28 |
Correct |
288 ms |
4700 KB |
Output is correct |
29 |
Correct |
17 ms |
1624 KB |
Output is correct |
30 |
Correct |
178 ms |
4180 KB |
Output is correct |
31 |
Correct |
180 ms |
4688 KB |
Output is correct |
32 |
Correct |
181 ms |
4688 KB |
Output is correct |
33 |
Correct |
288 ms |
4548 KB |
Output is correct |
34 |
Correct |
258 ms |
4688 KB |
Output is correct |
35 |
Correct |
293 ms |
4700 KB |
Output is correct |
36 |
Correct |
292 ms |
4696 KB |
Output is correct |
37 |
Correct |
289 ms |
4724 KB |
Output is correct |
38 |
Correct |
283 ms |
4700 KB |
Output is correct |
39 |
Correct |
288 ms |
4720 KB |
Output is correct |
40 |
Correct |
307 ms |
5460 KB |
Output is correct |
41 |
Correct |
130 ms |
4656 KB |
Output is correct |
42 |
Correct |
298 ms |
5460 KB |
Output is correct |
43 |
Correct |
284 ms |
4948 KB |
Output is correct |
44 |
Correct |
286 ms |
5204 KB |
Output is correct |
45 |
Correct |
355 ms |
8484 KB |
Output is correct |
46 |
Correct |
134 ms |
4944 KB |
Output is correct |
47 |
Correct |
338 ms |
8500 KB |
Output is correct |
48 |
Correct |
313 ms |
6636 KB |
Output is correct |
49 |
Correct |
315 ms |
7400 KB |
Output is correct |