# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
825050 |
2023-08-14T14:02:23 Z |
zsombor |
Lottery (CEOI18_lot) |
C++17 |
|
1807 ms |
8268 KB |
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, l, q, k, L, R, M, b;
vector <int> a(1e4, 0);
vector <int> v(1e4 + 1, 0);
vector <pair<int, int>> Q;
vector <vector<int>> ans(101, vector <int>(1e4 + 1));
vector <int> nw(101);
int bin(int val) {
L = -1, R = q;
while (R - L > 1) {
M = (L + R) / 2;
(Q[M].first < val ? L = M : R = M);
}
return R;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> l;
for (int i = 0; i < n; i++) cin >> a[i];
cin >> q;
Q.resize(q);
for (int i = 0; i < q; i++) {
cin >> Q[i].first;
Q[i].second = i;
}
sort(Q.begin(), Q.end());
for (int i = 1; i <= n - l; i++) {
for (int j = 0; j < n - i; j++) {
if (a[j] != a[j + i]) continue;
L = max(0, j - l + 1), R = min(j + i, n - l);
R -= i;
if (L > R) continue;
v[R]++;
if (L) v[L - 1]--;
}
for (int j = n - l - i; j >= 0; j--) {
v[j] += v[j + 1];
v[j + 1] = 0;
b = bin(l - v[j]);
ans[b][j]++;
ans[b][j + i]++;
}
v[0] = 0;
}
for (int i = 1; i < q; i++) {
for (int j = 0; j < n; j++) {
ans[i][j] += ans[i - 1][j];
}
}
for (int i = 0; i < q; i++) nw[Q[i].second] = i;
for (int i = 0; i < q; i++) {
for (int j = 0; j <= n - l; j++) {
cout << ans[nw[i]][j] << " ";
}
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4432 KB |
Output is correct |
2 |
Correct |
2 ms |
4308 KB |
Output is correct |
3 |
Correct |
2 ms |
4380 KB |
Output is correct |
4 |
Correct |
2 ms |
4308 KB |
Output is correct |
5 |
Correct |
2 ms |
4384 KB |
Output is correct |
6 |
Correct |
3 ms |
4332 KB |
Output is correct |
7 |
Correct |
2 ms |
4388 KB |
Output is correct |
8 |
Correct |
3 ms |
4308 KB |
Output is correct |
9 |
Correct |
3 ms |
4308 KB |
Output is correct |
10 |
Correct |
3 ms |
4380 KB |
Output is correct |
11 |
Correct |
3 ms |
4316 KB |
Output is correct |
12 |
Correct |
3 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4432 KB |
Output is correct |
2 |
Correct |
2 ms |
4308 KB |
Output is correct |
3 |
Correct |
2 ms |
4380 KB |
Output is correct |
4 |
Correct |
2 ms |
4308 KB |
Output is correct |
5 |
Correct |
2 ms |
4384 KB |
Output is correct |
6 |
Correct |
3 ms |
4332 KB |
Output is correct |
7 |
Correct |
2 ms |
4388 KB |
Output is correct |
8 |
Correct |
3 ms |
4308 KB |
Output is correct |
9 |
Correct |
3 ms |
4308 KB |
Output is correct |
10 |
Correct |
3 ms |
4380 KB |
Output is correct |
11 |
Correct |
3 ms |
4316 KB |
Output is correct |
12 |
Correct |
3 ms |
4308 KB |
Output is correct |
13 |
Correct |
30 ms |
4384 KB |
Output is correct |
14 |
Correct |
18 ms |
4388 KB |
Output is correct |
15 |
Correct |
18 ms |
4436 KB |
Output is correct |
16 |
Correct |
42 ms |
4380 KB |
Output is correct |
17 |
Correct |
31 ms |
4380 KB |
Output is correct |
18 |
Correct |
31 ms |
4388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
594 ms |
4380 KB |
Output is correct |
2 |
Correct |
575 ms |
4380 KB |
Output is correct |
3 |
Correct |
364 ms |
4396 KB |
Output is correct |
4 |
Correct |
303 ms |
4436 KB |
Output is correct |
5 |
Correct |
127 ms |
4436 KB |
Output is correct |
6 |
Correct |
438 ms |
4456 KB |
Output is correct |
7 |
Correct |
153 ms |
4460 KB |
Output is correct |
8 |
Correct |
230 ms |
4456 KB |
Output is correct |
9 |
Correct |
301 ms |
4460 KB |
Output is correct |
10 |
Correct |
308 ms |
4456 KB |
Output is correct |
11 |
Correct |
20 ms |
4384 KB |
Output is correct |
12 |
Correct |
186 ms |
4460 KB |
Output is correct |
13 |
Correct |
143 ms |
4436 KB |
Output is correct |
14 |
Correct |
162 ms |
4460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
594 ms |
4380 KB |
Output is correct |
2 |
Correct |
575 ms |
4380 KB |
Output is correct |
3 |
Correct |
364 ms |
4396 KB |
Output is correct |
4 |
Correct |
303 ms |
4436 KB |
Output is correct |
5 |
Correct |
127 ms |
4436 KB |
Output is correct |
6 |
Correct |
438 ms |
4456 KB |
Output is correct |
7 |
Correct |
153 ms |
4460 KB |
Output is correct |
8 |
Correct |
230 ms |
4456 KB |
Output is correct |
9 |
Correct |
301 ms |
4460 KB |
Output is correct |
10 |
Correct |
308 ms |
4456 KB |
Output is correct |
11 |
Correct |
20 ms |
4384 KB |
Output is correct |
12 |
Correct |
186 ms |
4460 KB |
Output is correct |
13 |
Correct |
143 ms |
4436 KB |
Output is correct |
14 |
Correct |
162 ms |
4460 KB |
Output is correct |
15 |
Correct |
353 ms |
4384 KB |
Output is correct |
16 |
Correct |
266 ms |
4464 KB |
Output is correct |
17 |
Correct |
326 ms |
4456 KB |
Output is correct |
18 |
Correct |
309 ms |
4456 KB |
Output is correct |
19 |
Correct |
304 ms |
4456 KB |
Output is correct |
20 |
Correct |
305 ms |
4468 KB |
Output is correct |
21 |
Correct |
354 ms |
4396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4432 KB |
Output is correct |
2 |
Correct |
2 ms |
4308 KB |
Output is correct |
3 |
Correct |
2 ms |
4380 KB |
Output is correct |
4 |
Correct |
2 ms |
4308 KB |
Output is correct |
5 |
Correct |
2 ms |
4384 KB |
Output is correct |
6 |
Correct |
3 ms |
4332 KB |
Output is correct |
7 |
Correct |
2 ms |
4388 KB |
Output is correct |
8 |
Correct |
3 ms |
4308 KB |
Output is correct |
9 |
Correct |
3 ms |
4308 KB |
Output is correct |
10 |
Correct |
3 ms |
4380 KB |
Output is correct |
11 |
Correct |
3 ms |
4316 KB |
Output is correct |
12 |
Correct |
3 ms |
4308 KB |
Output is correct |
13 |
Correct |
30 ms |
4384 KB |
Output is correct |
14 |
Correct |
18 ms |
4388 KB |
Output is correct |
15 |
Correct |
18 ms |
4436 KB |
Output is correct |
16 |
Correct |
42 ms |
4380 KB |
Output is correct |
17 |
Correct |
31 ms |
4380 KB |
Output is correct |
18 |
Correct |
31 ms |
4388 KB |
Output is correct |
19 |
Correct |
594 ms |
4380 KB |
Output is correct |
20 |
Correct |
575 ms |
4380 KB |
Output is correct |
21 |
Correct |
364 ms |
4396 KB |
Output is correct |
22 |
Correct |
303 ms |
4436 KB |
Output is correct |
23 |
Correct |
127 ms |
4436 KB |
Output is correct |
24 |
Correct |
438 ms |
4456 KB |
Output is correct |
25 |
Correct |
153 ms |
4460 KB |
Output is correct |
26 |
Correct |
230 ms |
4456 KB |
Output is correct |
27 |
Correct |
301 ms |
4460 KB |
Output is correct |
28 |
Correct |
308 ms |
4456 KB |
Output is correct |
29 |
Correct |
20 ms |
4384 KB |
Output is correct |
30 |
Correct |
186 ms |
4460 KB |
Output is correct |
31 |
Correct |
143 ms |
4436 KB |
Output is correct |
32 |
Correct |
162 ms |
4460 KB |
Output is correct |
33 |
Correct |
353 ms |
4384 KB |
Output is correct |
34 |
Correct |
266 ms |
4464 KB |
Output is correct |
35 |
Correct |
326 ms |
4456 KB |
Output is correct |
36 |
Correct |
309 ms |
4456 KB |
Output is correct |
37 |
Correct |
304 ms |
4456 KB |
Output is correct |
38 |
Correct |
305 ms |
4468 KB |
Output is correct |
39 |
Correct |
354 ms |
4396 KB |
Output is correct |
40 |
Correct |
1080 ms |
5144 KB |
Output is correct |
41 |
Correct |
23 ms |
4512 KB |
Output is correct |
42 |
Correct |
962 ms |
5160 KB |
Output is correct |
43 |
Correct |
916 ms |
4848 KB |
Output is correct |
44 |
Correct |
945 ms |
4972 KB |
Output is correct |
45 |
Correct |
1807 ms |
8216 KB |
Output is correct |
46 |
Correct |
33 ms |
4688 KB |
Output is correct |
47 |
Correct |
1451 ms |
8268 KB |
Output is correct |
48 |
Correct |
1324 ms |
6508 KB |
Output is correct |
49 |
Correct |
1340 ms |
7172 KB |
Output is correct |