#include <bits/stdc++.h>
using namespace std;
int n,l,i,j,k,m,d;
int mas[100001],fix[100001],where[100001],pre[10001][102],ans[101][10001];
pair <int,int> q[101];
int main() {
cin>>n>>l;
for (i=1;i<=n;i++)
cin>>mas[i];
cin>>m;
for (i=1;i<=m;i++) {
cin>>d;
q[i]={d,i};
}
sort(q+1,q+m+1);
for (i=m;i>0;i--)
where[q[i].first]=i;
for (i=10000;i>=0;i--)
if (!where[i])
where[i]=where[i+1];
for (d=1;d<=(n-l);d++) {
for (i=1;i<=n;i++) {
fix[i]=fix[i-1];
if (mas[i]==mas[i+d])
fix[i]++;
}
for (i=1;(i+d)<=(n-l+1);i++) {
pre[i][where[l-fix[i+l-1]+fix[i-1]]]++;
pre[i+d][where[l-fix[i+l-1]+fix[i-1]]]++;
}
}
for (i=1;i<=m;i++)
for (j=1;j<=(n-l+1);j++) {
ans[q[i].second][j]=pre[j][i];
pre[j][i+1]+=pre[j][i];
}
for (i=1;i<=m;i++) {
for (j=1;j<(n-l+1);j++)
cout<<ans[i][j]<<" ";
cout<<ans[i][n-l+1]<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
13 |
Correct |
28 ms |
1272 KB |
Output is correct |
14 |
Correct |
19 ms |
1272 KB |
Output is correct |
15 |
Correct |
18 ms |
1144 KB |
Output is correct |
16 |
Correct |
28 ms |
1528 KB |
Output is correct |
17 |
Correct |
25 ms |
1400 KB |
Output is correct |
18 |
Correct |
25 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
804 ms |
4504 KB |
Output is correct |
2 |
Correct |
802 ms |
4548 KB |
Output is correct |
3 |
Correct |
621 ms |
4572 KB |
Output is correct |
4 |
Correct |
619 ms |
4544 KB |
Output is correct |
5 |
Correct |
236 ms |
2680 KB |
Output is correct |
6 |
Correct |
563 ms |
4344 KB |
Output is correct |
7 |
Correct |
251 ms |
2680 KB |
Output is correct |
8 |
Correct |
400 ms |
3448 KB |
Output is correct |
9 |
Correct |
590 ms |
4492 KB |
Output is correct |
10 |
Correct |
608 ms |
4504 KB |
Output is correct |
11 |
Correct |
32 ms |
1144 KB |
Output is correct |
12 |
Correct |
340 ms |
3364 KB |
Output is correct |
13 |
Correct |
287 ms |
3036 KB |
Output is correct |
14 |
Correct |
289 ms |
2936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
804 ms |
4504 KB |
Output is correct |
2 |
Correct |
802 ms |
4548 KB |
Output is correct |
3 |
Correct |
621 ms |
4572 KB |
Output is correct |
4 |
Correct |
619 ms |
4544 KB |
Output is correct |
5 |
Correct |
236 ms |
2680 KB |
Output is correct |
6 |
Correct |
563 ms |
4344 KB |
Output is correct |
7 |
Correct |
251 ms |
2680 KB |
Output is correct |
8 |
Correct |
400 ms |
3448 KB |
Output is correct |
9 |
Correct |
590 ms |
4492 KB |
Output is correct |
10 |
Correct |
608 ms |
4504 KB |
Output is correct |
11 |
Correct |
32 ms |
1144 KB |
Output is correct |
12 |
Correct |
340 ms |
3364 KB |
Output is correct |
13 |
Correct |
287 ms |
3036 KB |
Output is correct |
14 |
Correct |
289 ms |
2936 KB |
Output is correct |
15 |
Correct |
598 ms |
4392 KB |
Output is correct |
16 |
Correct |
533 ms |
4192 KB |
Output is correct |
17 |
Correct |
627 ms |
4600 KB |
Output is correct |
18 |
Correct |
615 ms |
4552 KB |
Output is correct |
19 |
Correct |
610 ms |
4588 KB |
Output is correct |
20 |
Correct |
614 ms |
4556 KB |
Output is correct |
21 |
Correct |
608 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
508 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
508 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
13 |
Correct |
28 ms |
1272 KB |
Output is correct |
14 |
Correct |
19 ms |
1272 KB |
Output is correct |
15 |
Correct |
18 ms |
1144 KB |
Output is correct |
16 |
Correct |
28 ms |
1528 KB |
Output is correct |
17 |
Correct |
25 ms |
1400 KB |
Output is correct |
18 |
Correct |
25 ms |
1400 KB |
Output is correct |
19 |
Correct |
804 ms |
4504 KB |
Output is correct |
20 |
Correct |
802 ms |
4548 KB |
Output is correct |
21 |
Correct |
621 ms |
4572 KB |
Output is correct |
22 |
Correct |
619 ms |
4544 KB |
Output is correct |
23 |
Correct |
236 ms |
2680 KB |
Output is correct |
24 |
Correct |
563 ms |
4344 KB |
Output is correct |
25 |
Correct |
251 ms |
2680 KB |
Output is correct |
26 |
Correct |
400 ms |
3448 KB |
Output is correct |
27 |
Correct |
590 ms |
4492 KB |
Output is correct |
28 |
Correct |
608 ms |
4504 KB |
Output is correct |
29 |
Correct |
32 ms |
1144 KB |
Output is correct |
30 |
Correct |
340 ms |
3364 KB |
Output is correct |
31 |
Correct |
287 ms |
3036 KB |
Output is correct |
32 |
Correct |
289 ms |
2936 KB |
Output is correct |
33 |
Correct |
598 ms |
4392 KB |
Output is correct |
34 |
Correct |
533 ms |
4192 KB |
Output is correct |
35 |
Correct |
627 ms |
4600 KB |
Output is correct |
36 |
Correct |
615 ms |
4552 KB |
Output is correct |
37 |
Correct |
610 ms |
4588 KB |
Output is correct |
38 |
Correct |
614 ms |
4556 KB |
Output is correct |
39 |
Correct |
608 ms |
4604 KB |
Output is correct |
40 |
Correct |
816 ms |
6040 KB |
Output is correct |
41 |
Correct |
38 ms |
1116 KB |
Output is correct |
42 |
Correct |
632 ms |
5980 KB |
Output is correct |
43 |
Correct |
600 ms |
5684 KB |
Output is correct |
44 |
Correct |
595 ms |
5724 KB |
Output is correct |
45 |
Correct |
938 ms |
12188 KB |
Output is correct |
46 |
Correct |
47 ms |
2040 KB |
Output is correct |
47 |
Correct |
720 ms |
12448 KB |
Output is correct |
48 |
Correct |
675 ms |
10436 KB |
Output is correct |
49 |
Correct |
680 ms |
11128 KB |
Output is correct |