# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
949519 |
2024-03-19T10:14:10 Z |
glebustim |
Lottery (CEOI18_lot) |
C++17 |
|
492 ms |
12628 KB |
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
fast;
int n, l;
cin >> n >> l;
vi a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
int q;
cin >> q;
vector<pii> qs(q);
for (int i = 0; i < q; ++i) {
cin >> qs[i].first;
qs[i].second = i;
}
sort(all(qs));
vi g(n + 1);
for (int i = 0; i <= n; ++i)
g[i] = lower_bound(all(qs), make_pair(i, 0)) - qs.begin();
vector<vi> d(n, vi(q + 1, 0));
for (int k = 1; k < n; ++k) {
vi b(n + 1, 0);
for (int i = 0; i + k < n; ++i) {
int j = i + k;
if (a[i] == a[j])
continue;
int lf = max(i - l + 1, 0), rg = i - max(j + l - n, 0);
if (lf <= rg) {
++b[lf];
--b[rg + 1];
}
}
int x = 0;
for (int i = 0; i + k + l <= n; ++i) {
int j = i + k;
x += b[i];
++d[i][g[x]];
++d[j][g[x]];
}
}
vector<vi> ans(q, vi(n - l + 1, 0));
for (int i = 0; i <= n - l; ++i) {
int x = 0;
for (int j = 0; j < q; ++j) {
x += d[i][j];
ans[qs[j].second][i] = x;
}
}
for (int i = 0; i < q; ++i) {
for (int j = 0; j <= n - l; ++j)
cout << ans[i][j] << ' ';
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
604 KB |
Output is correct |
14 |
Correct |
9 ms |
860 KB |
Output is correct |
15 |
Correct |
9 ms |
596 KB |
Output is correct |
16 |
Correct |
11 ms |
860 KB |
Output is correct |
17 |
Correct |
11 ms |
912 KB |
Output is correct |
18 |
Correct |
11 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
405 ms |
1116 KB |
Output is correct |
2 |
Correct |
398 ms |
1116 KB |
Output is correct |
3 |
Correct |
262 ms |
1364 KB |
Output is correct |
4 |
Correct |
225 ms |
1120 KB |
Output is correct |
5 |
Correct |
109 ms |
1116 KB |
Output is correct |
6 |
Correct |
217 ms |
1116 KB |
Output is correct |
7 |
Correct |
75 ms |
1116 KB |
Output is correct |
8 |
Correct |
112 ms |
1116 KB |
Output is correct |
9 |
Correct |
221 ms |
1116 KB |
Output is correct |
10 |
Correct |
220 ms |
1124 KB |
Output is correct |
11 |
Correct |
14 ms |
600 KB |
Output is correct |
12 |
Correct |
151 ms |
1056 KB |
Output is correct |
13 |
Correct |
151 ms |
1112 KB |
Output is correct |
14 |
Correct |
141 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
405 ms |
1116 KB |
Output is correct |
2 |
Correct |
398 ms |
1116 KB |
Output is correct |
3 |
Correct |
262 ms |
1364 KB |
Output is correct |
4 |
Correct |
225 ms |
1120 KB |
Output is correct |
5 |
Correct |
109 ms |
1116 KB |
Output is correct |
6 |
Correct |
217 ms |
1116 KB |
Output is correct |
7 |
Correct |
75 ms |
1116 KB |
Output is correct |
8 |
Correct |
112 ms |
1116 KB |
Output is correct |
9 |
Correct |
221 ms |
1116 KB |
Output is correct |
10 |
Correct |
220 ms |
1124 KB |
Output is correct |
11 |
Correct |
14 ms |
600 KB |
Output is correct |
12 |
Correct |
151 ms |
1056 KB |
Output is correct |
13 |
Correct |
151 ms |
1112 KB |
Output is correct |
14 |
Correct |
141 ms |
1116 KB |
Output is correct |
15 |
Correct |
250 ms |
1116 KB |
Output is correct |
16 |
Correct |
198 ms |
1112 KB |
Output is correct |
17 |
Correct |
238 ms |
1116 KB |
Output is correct |
18 |
Correct |
225 ms |
1116 KB |
Output is correct |
19 |
Correct |
225 ms |
1112 KB |
Output is correct |
20 |
Correct |
224 ms |
1364 KB |
Output is correct |
21 |
Correct |
227 ms |
1120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
604 KB |
Output is correct |
14 |
Correct |
9 ms |
860 KB |
Output is correct |
15 |
Correct |
9 ms |
596 KB |
Output is correct |
16 |
Correct |
11 ms |
860 KB |
Output is correct |
17 |
Correct |
11 ms |
912 KB |
Output is correct |
18 |
Correct |
11 ms |
860 KB |
Output is correct |
19 |
Correct |
405 ms |
1116 KB |
Output is correct |
20 |
Correct |
398 ms |
1116 KB |
Output is correct |
21 |
Correct |
262 ms |
1364 KB |
Output is correct |
22 |
Correct |
225 ms |
1120 KB |
Output is correct |
23 |
Correct |
109 ms |
1116 KB |
Output is correct |
24 |
Correct |
217 ms |
1116 KB |
Output is correct |
25 |
Correct |
75 ms |
1116 KB |
Output is correct |
26 |
Correct |
112 ms |
1116 KB |
Output is correct |
27 |
Correct |
221 ms |
1116 KB |
Output is correct |
28 |
Correct |
220 ms |
1124 KB |
Output is correct |
29 |
Correct |
14 ms |
600 KB |
Output is correct |
30 |
Correct |
151 ms |
1056 KB |
Output is correct |
31 |
Correct |
151 ms |
1112 KB |
Output is correct |
32 |
Correct |
141 ms |
1116 KB |
Output is correct |
33 |
Correct |
250 ms |
1116 KB |
Output is correct |
34 |
Correct |
198 ms |
1112 KB |
Output is correct |
35 |
Correct |
238 ms |
1116 KB |
Output is correct |
36 |
Correct |
225 ms |
1116 KB |
Output is correct |
37 |
Correct |
225 ms |
1112 KB |
Output is correct |
38 |
Correct |
224 ms |
1364 KB |
Output is correct |
39 |
Correct |
227 ms |
1120 KB |
Output is correct |
40 |
Correct |
440 ms |
3156 KB |
Output is correct |
41 |
Correct |
75 ms |
1872 KB |
Output is correct |
42 |
Correct |
263 ms |
3304 KB |
Output is correct |
43 |
Correct |
263 ms |
2864 KB |
Output is correct |
44 |
Correct |
260 ms |
2900 KB |
Output is correct |
45 |
Correct |
492 ms |
12628 KB |
Output is correct |
46 |
Correct |
84 ms |
5460 KB |
Output is correct |
47 |
Correct |
314 ms |
12628 KB |
Output is correct |
48 |
Correct |
302 ms |
10616 KB |
Output is correct |
49 |
Correct |
306 ms |
11288 KB |
Output is correct |