# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
248773 |
2020-07-13T10:54:58 Z |
Sorting |
Lottery (CEOI18_lot) |
C++14 |
|
1219 ms |
25720 KB |
#include <bits/stdc++.h>
using namespace std;
const short k_N = 1e4 + 3;
const short k_Q = 1e3 + 3;
int n, l;
int a[k_N];
short cnt[k_N][k_Q];
short prefix[k_N];
pair<short, short> queries[k_Q];
short ans[k_Q][k_N];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> l;
for(int i = 0; i < n; ++i)
cin >> a[i];
int q;
cin >> q;
for(int i = 0; i < q; ++i){
cin >> queries[i].first;
queries[i].second = i;
}
sort(queries, queries + q);
for(int d = 1; d < n - l + 1; d++){
prefix[0] = (a[0] != a[d]);
for(int i = 1; i < n - d; ++i)
prefix[i] = (a[i] != a[i + d]) + prefix[i - 1];
for(int i = 0; i < n - l + 1 - d; ++i){
short sum = prefix[i + l - 1];
if(i)
sum -= prefix[i - 1];
int idx = lower_bound(queries, queries + q, pair<short, short>{sum, -1}) - queries;
cnt[i][idx]++;
cnt[i + d][idx]++;
}
}
for(int i = 0; i < n - l + 1; ++i)
for(int j = 1; j < q; ++j)
cnt[i][j] += cnt[i][j - 1];
for(int i = 0; i < q; ++i)
for(int j = 0; j < n - l + 1; ++j)
ans[queries[i].second][j] = cnt[j][i];
for(int i = 0; i < q; ++i){
for(int j = 0; j < n - l + 1; ++j)
cout << ans[i][j] << " ";
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
640 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
11 |
Correct |
2 ms |
1024 KB |
Output is correct |
12 |
Correct |
1 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
640 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
11 |
Correct |
2 ms |
1024 KB |
Output is correct |
12 |
Correct |
1 ms |
1024 KB |
Output is correct |
13 |
Correct |
21 ms |
4352 KB |
Output is correct |
14 |
Correct |
13 ms |
3200 KB |
Output is correct |
15 |
Correct |
11 ms |
3072 KB |
Output is correct |
16 |
Correct |
19 ms |
4096 KB |
Output is correct |
17 |
Correct |
17 ms |
3840 KB |
Output is correct |
18 |
Correct |
17 ms |
3856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
568 ms |
20216 KB |
Output is correct |
2 |
Correct |
550 ms |
20100 KB |
Output is correct |
3 |
Correct |
542 ms |
20096 KB |
Output is correct |
4 |
Correct |
525 ms |
19832 KB |
Output is correct |
5 |
Correct |
143 ms |
10368 KB |
Output is correct |
6 |
Correct |
481 ms |
18816 KB |
Output is correct |
7 |
Correct |
155 ms |
10368 KB |
Output is correct |
8 |
Correct |
285 ms |
14328 KB |
Output is correct |
9 |
Correct |
498 ms |
19532 KB |
Output is correct |
10 |
Correct |
509 ms |
19836 KB |
Output is correct |
11 |
Correct |
15 ms |
4224 KB |
Output is correct |
12 |
Correct |
256 ms |
14200 KB |
Output is correct |
13 |
Correct |
209 ms |
12160 KB |
Output is correct |
14 |
Correct |
194 ms |
12160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
568 ms |
20216 KB |
Output is correct |
2 |
Correct |
550 ms |
20100 KB |
Output is correct |
3 |
Correct |
542 ms |
20096 KB |
Output is correct |
4 |
Correct |
525 ms |
19832 KB |
Output is correct |
5 |
Correct |
143 ms |
10368 KB |
Output is correct |
6 |
Correct |
481 ms |
18816 KB |
Output is correct |
7 |
Correct |
155 ms |
10368 KB |
Output is correct |
8 |
Correct |
285 ms |
14328 KB |
Output is correct |
9 |
Correct |
498 ms |
19532 KB |
Output is correct |
10 |
Correct |
509 ms |
19836 KB |
Output is correct |
11 |
Correct |
15 ms |
4224 KB |
Output is correct |
12 |
Correct |
256 ms |
14200 KB |
Output is correct |
13 |
Correct |
209 ms |
12160 KB |
Output is correct |
14 |
Correct |
194 ms |
12160 KB |
Output is correct |
15 |
Correct |
488 ms |
19456 KB |
Output is correct |
16 |
Correct |
427 ms |
18176 KB |
Output is correct |
17 |
Correct |
530 ms |
20216 KB |
Output is correct |
18 |
Correct |
509 ms |
20088 KB |
Output is correct |
19 |
Correct |
538 ms |
19968 KB |
Output is correct |
20 |
Correct |
530 ms |
20088 KB |
Output is correct |
21 |
Correct |
519 ms |
19968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
640 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
512 KB |
Output is correct |
7 |
Correct |
1 ms |
512 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
1024 KB |
Output is correct |
11 |
Correct |
2 ms |
1024 KB |
Output is correct |
12 |
Correct |
1 ms |
1024 KB |
Output is correct |
13 |
Correct |
21 ms |
4352 KB |
Output is correct |
14 |
Correct |
13 ms |
3200 KB |
Output is correct |
15 |
Correct |
11 ms |
3072 KB |
Output is correct |
16 |
Correct |
19 ms |
4096 KB |
Output is correct |
17 |
Correct |
17 ms |
3840 KB |
Output is correct |
18 |
Correct |
17 ms |
3856 KB |
Output is correct |
19 |
Correct |
568 ms |
20216 KB |
Output is correct |
20 |
Correct |
550 ms |
20100 KB |
Output is correct |
21 |
Correct |
542 ms |
20096 KB |
Output is correct |
22 |
Correct |
525 ms |
19832 KB |
Output is correct |
23 |
Correct |
143 ms |
10368 KB |
Output is correct |
24 |
Correct |
481 ms |
18816 KB |
Output is correct |
25 |
Correct |
155 ms |
10368 KB |
Output is correct |
26 |
Correct |
285 ms |
14328 KB |
Output is correct |
27 |
Correct |
498 ms |
19532 KB |
Output is correct |
28 |
Correct |
509 ms |
19836 KB |
Output is correct |
29 |
Correct |
15 ms |
4224 KB |
Output is correct |
30 |
Correct |
256 ms |
14200 KB |
Output is correct |
31 |
Correct |
209 ms |
12160 KB |
Output is correct |
32 |
Correct |
194 ms |
12160 KB |
Output is correct |
33 |
Correct |
488 ms |
19456 KB |
Output is correct |
34 |
Correct |
427 ms |
18176 KB |
Output is correct |
35 |
Correct |
530 ms |
20216 KB |
Output is correct |
36 |
Correct |
509 ms |
20088 KB |
Output is correct |
37 |
Correct |
538 ms |
19968 KB |
Output is correct |
38 |
Correct |
530 ms |
20088 KB |
Output is correct |
39 |
Correct |
519 ms |
19968 KB |
Output is correct |
40 |
Correct |
874 ms |
21068 KB |
Output is correct |
41 |
Correct |
18 ms |
2688 KB |
Output is correct |
42 |
Correct |
790 ms |
21032 KB |
Output is correct |
43 |
Correct |
768 ms |
20080 KB |
Output is correct |
44 |
Correct |
737 ms |
20212 KB |
Output is correct |
45 |
Correct |
1219 ms |
25720 KB |
Output is correct |
46 |
Correct |
25 ms |
3448 KB |
Output is correct |
47 |
Correct |
1022 ms |
25720 KB |
Output is correct |
48 |
Correct |
897 ms |
23288 KB |
Output is correct |
49 |
Correct |
937 ms |
24180 KB |
Output is correct |