#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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
548 KB |
Output is correct |
7 |
Correct |
2 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
800 KB |
Output is correct |
11 |
Correct |
3 ms |
808 KB |
Output is correct |
12 |
Correct |
3 ms |
944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
548 KB |
Output is correct |
7 |
Correct |
2 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
800 KB |
Output is correct |
11 |
Correct |
3 ms |
808 KB |
Output is correct |
12 |
Correct |
3 ms |
944 KB |
Output is correct |
13 |
Correct |
21 ms |
1664 KB |
Output is correct |
14 |
Correct |
12 ms |
1664 KB |
Output is correct |
15 |
Correct |
11 ms |
1664 KB |
Output is correct |
16 |
Correct |
16 ms |
1664 KB |
Output is correct |
17 |
Correct |
15 ms |
1664 KB |
Output is correct |
18 |
Correct |
23 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
455 ms |
5120 KB |
Output is correct |
2 |
Correct |
487 ms |
5120 KB |
Output is correct |
3 |
Correct |
447 ms |
5160 KB |
Output is correct |
4 |
Correct |
443 ms |
5160 KB |
Output is correct |
5 |
Correct |
142 ms |
5160 KB |
Output is correct |
6 |
Correct |
385 ms |
5160 KB |
Output is correct |
7 |
Correct |
139 ms |
5160 KB |
Output is correct |
8 |
Correct |
248 ms |
5160 KB |
Output is correct |
9 |
Correct |
502 ms |
5488 KB |
Output is correct |
10 |
Correct |
429 ms |
5752 KB |
Output is correct |
11 |
Correct |
18 ms |
5752 KB |
Output is correct |
12 |
Correct |
234 ms |
5752 KB |
Output is correct |
13 |
Correct |
188 ms |
5752 KB |
Output is correct |
14 |
Correct |
179 ms |
5752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
455 ms |
5120 KB |
Output is correct |
2 |
Correct |
487 ms |
5120 KB |
Output is correct |
3 |
Correct |
447 ms |
5160 KB |
Output is correct |
4 |
Correct |
443 ms |
5160 KB |
Output is correct |
5 |
Correct |
142 ms |
5160 KB |
Output is correct |
6 |
Correct |
385 ms |
5160 KB |
Output is correct |
7 |
Correct |
139 ms |
5160 KB |
Output is correct |
8 |
Correct |
248 ms |
5160 KB |
Output is correct |
9 |
Correct |
502 ms |
5488 KB |
Output is correct |
10 |
Correct |
429 ms |
5752 KB |
Output is correct |
11 |
Correct |
18 ms |
5752 KB |
Output is correct |
12 |
Correct |
234 ms |
5752 KB |
Output is correct |
13 |
Correct |
188 ms |
5752 KB |
Output is correct |
14 |
Correct |
179 ms |
5752 KB |
Output is correct |
15 |
Correct |
422 ms |
5980 KB |
Output is correct |
16 |
Correct |
381 ms |
5980 KB |
Output is correct |
17 |
Correct |
444 ms |
6272 KB |
Output is correct |
18 |
Correct |
464 ms |
6460 KB |
Output is correct |
19 |
Correct |
429 ms |
6556 KB |
Output is correct |
20 |
Correct |
448 ms |
6556 KB |
Output is correct |
21 |
Correct |
444 ms |
6760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
548 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
548 KB |
Output is correct |
7 |
Correct |
2 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
800 KB |
Output is correct |
11 |
Correct |
3 ms |
808 KB |
Output is correct |
12 |
Correct |
3 ms |
944 KB |
Output is correct |
13 |
Correct |
21 ms |
1664 KB |
Output is correct |
14 |
Correct |
12 ms |
1664 KB |
Output is correct |
15 |
Correct |
11 ms |
1664 KB |
Output is correct |
16 |
Correct |
16 ms |
1664 KB |
Output is correct |
17 |
Correct |
15 ms |
1664 KB |
Output is correct |
18 |
Correct |
23 ms |
1664 KB |
Output is correct |
19 |
Correct |
455 ms |
5120 KB |
Output is correct |
20 |
Correct |
487 ms |
5120 KB |
Output is correct |
21 |
Correct |
447 ms |
5160 KB |
Output is correct |
22 |
Correct |
443 ms |
5160 KB |
Output is correct |
23 |
Correct |
142 ms |
5160 KB |
Output is correct |
24 |
Correct |
385 ms |
5160 KB |
Output is correct |
25 |
Correct |
139 ms |
5160 KB |
Output is correct |
26 |
Correct |
248 ms |
5160 KB |
Output is correct |
27 |
Correct |
502 ms |
5488 KB |
Output is correct |
28 |
Correct |
429 ms |
5752 KB |
Output is correct |
29 |
Correct |
18 ms |
5752 KB |
Output is correct |
30 |
Correct |
234 ms |
5752 KB |
Output is correct |
31 |
Correct |
188 ms |
5752 KB |
Output is correct |
32 |
Correct |
179 ms |
5752 KB |
Output is correct |
33 |
Correct |
422 ms |
5980 KB |
Output is correct |
34 |
Correct |
381 ms |
5980 KB |
Output is correct |
35 |
Correct |
444 ms |
6272 KB |
Output is correct |
36 |
Correct |
464 ms |
6460 KB |
Output is correct |
37 |
Correct |
429 ms |
6556 KB |
Output is correct |
38 |
Correct |
448 ms |
6556 KB |
Output is correct |
39 |
Correct |
444 ms |
6760 KB |
Output is correct |
40 |
Correct |
452 ms |
7500 KB |
Output is correct |
41 |
Correct |
19 ms |
7500 KB |
Output is correct |
42 |
Correct |
462 ms |
7552 KB |
Output is correct |
43 |
Correct |
442 ms |
7552 KB |
Output is correct |
44 |
Correct |
457 ms |
7552 KB |
Output is correct |
45 |
Correct |
510 ms |
10796 KB |
Output is correct |
46 |
Correct |
27 ms |
10796 KB |
Output is correct |
47 |
Correct |
522 ms |
10916 KB |
Output is correct |
48 |
Correct |
491 ms |
10916 KB |
Output is correct |
49 |
Correct |
491 ms |
10916 KB |
Output is correct |