Submission #878428

# Submission time Handle Problem Language Result Execution time Memory
878428 2023-11-24T10:51:49 Z Trisanu_Das Lottery (CEOI18_lot) C++17
100 / 100
274 ms 8292 KB
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=1e4, mxQ=100;
int n, l, a[mxN], ps[mxN+1], ans[mxN][mxQ+1], b[mxN+1], q, k[mxQ], k2[mxQ+1];
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> l;
	for(int i=0; i<n; ++i)
		cin >> a[i];
	cin >> q;
	for(int i=0; i<q; ++i) cin >> k[i], k2[i]=k[i];
	sort(k2, k2+q);
	k2[q]=l;
	for(int i=0, p=-1; i<=q; ++i) {
		for(int j=p+1; j<=k2[i]; ++j) b[j]=i;
		p=k2[i];
	}
	for(int i=1; i<n-l+1; ++i) {
		for(int j=0; i+j<n; ++j) ps[j+1]=ps[j]+(a[j]!=a[i+j]);
		for(int j=0; j+l+i<=n; ++j) {
			++ans[j][b[ps[j+l]-ps[j]]];
			++ans[j+i][b[ps[j+l]-ps[j]]];
		}
	}
	for(int i=0; i<n-l+1; ++i) for(int j=0; j<q-1; ++j) ans[i][j+1]+=ans[i][j];
	for(int i=0; i<q; ++i) {
		for(int j=0; j<n-l+1; ++j) cout << ans[j][lower_bound(k2, k2+q, k[i])-k2] << " ";
		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 460 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 460 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 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 460 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 460 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 348 KB Output is correct
13 Correct 8 ms 2648 KB Output is correct
14 Correct 6 ms 2908 KB Output is correct
15 Correct 5 ms 2720 KB Output is correct
16 Correct 8 ms 2648 KB Output is correct
17 Correct 7 ms 2540 KB Output is correct
18 Correct 7 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 4492 KB Output is correct
2 Correct 205 ms 4504 KB Output is correct
3 Correct 215 ms 4488 KB Output is correct
4 Correct 202 ms 4496 KB Output is correct
5 Correct 63 ms 2648 KB Output is correct
6 Correct 176 ms 4296 KB Output is correct
7 Correct 64 ms 2652 KB Output is correct
8 Correct 107 ms 3416 KB Output is correct
9 Correct 201 ms 4448 KB Output is correct
10 Correct 222 ms 4484 KB Output is correct
11 Correct 10 ms 2704 KB Output is correct
12 Correct 103 ms 3364 KB Output is correct
13 Correct 88 ms 3160 KB Output is correct
14 Correct 84 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 4492 KB Output is correct
2 Correct 205 ms 4504 KB Output is correct
3 Correct 215 ms 4488 KB Output is correct
4 Correct 202 ms 4496 KB Output is correct
5 Correct 63 ms 2648 KB Output is correct
6 Correct 176 ms 4296 KB Output is correct
7 Correct 64 ms 2652 KB Output is correct
8 Correct 107 ms 3416 KB Output is correct
9 Correct 201 ms 4448 KB Output is correct
10 Correct 222 ms 4484 KB Output is correct
11 Correct 10 ms 2704 KB Output is correct
12 Correct 103 ms 3364 KB Output is correct
13 Correct 88 ms 3160 KB Output is correct
14 Correct 84 ms 2908 KB Output is correct
15 Correct 198 ms 4184 KB Output is correct
16 Correct 178 ms 4200 KB Output is correct
17 Correct 212 ms 4440 KB Output is correct
18 Correct 214 ms 4440 KB Output is correct
19 Correct 201 ms 4440 KB Output is correct
20 Correct 222 ms 4440 KB Output is correct
21 Correct 205 ms 4788 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 460 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 460 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 348 KB Output is correct
13 Correct 8 ms 2648 KB Output is correct
14 Correct 6 ms 2908 KB Output is correct
15 Correct 5 ms 2720 KB Output is correct
16 Correct 8 ms 2648 KB Output is correct
17 Correct 7 ms 2540 KB Output is correct
18 Correct 7 ms 2652 KB Output is correct
19 Correct 217 ms 4492 KB Output is correct
20 Correct 205 ms 4504 KB Output is correct
21 Correct 215 ms 4488 KB Output is correct
22 Correct 202 ms 4496 KB Output is correct
23 Correct 63 ms 2648 KB Output is correct
24 Correct 176 ms 4296 KB Output is correct
25 Correct 64 ms 2652 KB Output is correct
26 Correct 107 ms 3416 KB Output is correct
27 Correct 201 ms 4448 KB Output is correct
28 Correct 222 ms 4484 KB Output is correct
29 Correct 10 ms 2704 KB Output is correct
30 Correct 103 ms 3364 KB Output is correct
31 Correct 88 ms 3160 KB Output is correct
32 Correct 84 ms 2908 KB Output is correct
33 Correct 198 ms 4184 KB Output is correct
34 Correct 178 ms 4200 KB Output is correct
35 Correct 212 ms 4440 KB Output is correct
36 Correct 214 ms 4440 KB Output is correct
37 Correct 201 ms 4440 KB Output is correct
38 Correct 222 ms 4440 KB Output is correct
39 Correct 205 ms 4788 KB Output is correct
40 Correct 224 ms 5216 KB Output is correct
41 Correct 11 ms 2904 KB Output is correct
42 Correct 216 ms 5224 KB Output is correct
43 Correct 212 ms 4652 KB Output is correct
44 Correct 209 ms 4664 KB Output is correct
45 Correct 274 ms 8048 KB Output is correct
46 Correct 16 ms 3160 KB Output is correct
47 Correct 262 ms 8292 KB Output is correct
48 Correct 251 ms 6480 KB Output is correct
49 Correct 256 ms 7180 KB Output is correct