#include<bits/stdc++.h>
using namespace std;
const int maxn=10000+5,maxq=100+2;
int q,n,l,dp[2][maxn],all[maxn],res[maxn][maxq],nx[maxn];
vector<int>allq,asly;
int main(){
cin>>n>>l;
for(int i=1;i<=n;i++){
cin>>all[i];
}
cin>>q;
allq.resize(q);
asly.resize(q);
for(int i=0;i<q;i++){
cin>>asly[i];
allq[i]=asly[i];
}
sort(allq.begin(),allq.end());
allq.resize(unique(allq.begin(),allq.end())-allq.begin());
for(int i=0;i<maxn;i++){
int p=lower_bound(allq.begin(),allq.end(),i)-allq.begin();
nx[i]=p;
}
for(int i=1;i<=n;i++){
for(int j=0;j<=n;j++){
swap(dp[0][j],dp[1][j]);
}
for(int j=0;j<i;j++){
if(j==0){
dp[1][j]=l;
continue;
}
dp[1][j]=dp[0][j-1];
if(all[i]!=all[j]){
dp[1][j]++;
}
if((j-1)-l+1<1||all[(j-1)-l+1]!=all[(i-1)-l+1]){
dp[1][j]--;
}
if(j>=l){
res[j][nx[dp[1][j]]]++;
res[i][nx[dp[1][j]]]++;
}
//cout<<i<<" "<<j<<" "<<dp[1][j]<<"\n";
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<q;j++){
res[i][j]+=res[i][j-1];
}
}
for(int i=0;i<q;i++){
int p=lower_bound(allq.begin(),allq.end(),asly[i])-allq.begin();
for(int j=l;j<=n;j++){
cout<<res[j][p]<<" ";
}
cout<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
392 KB |
Output is correct |
3 |
Correct |
1 ms |
532 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
624 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
392 KB |
Output is correct |
3 |
Correct |
1 ms |
532 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
624 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
14 ms |
2652 KB |
Output is correct |
14 |
Correct |
10 ms |
2760 KB |
Output is correct |
15 |
Correct |
9 ms |
2652 KB |
Output is correct |
16 |
Correct |
12 ms |
2652 KB |
Output is correct |
17 |
Correct |
12 ms |
2740 KB |
Output is correct |
18 |
Correct |
17 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
4524 KB |
Output is correct |
2 |
Correct |
493 ms |
4576 KB |
Output is correct |
3 |
Correct |
301 ms |
4596 KB |
Output is correct |
4 |
Correct |
260 ms |
4424 KB |
Output is correct |
5 |
Correct |
217 ms |
4432 KB |
Output is correct |
6 |
Correct |
237 ms |
4344 KB |
Output is correct |
7 |
Correct |
226 ms |
4516 KB |
Output is correct |
8 |
Correct |
217 ms |
4432 KB |
Output is correct |
9 |
Correct |
231 ms |
4432 KB |
Output is correct |
10 |
Correct |
233 ms |
4432 KB |
Output is correct |
11 |
Correct |
18 ms |
2392 KB |
Output is correct |
12 |
Correct |
153 ms |
3920 KB |
Output is correct |
13 |
Correct |
176 ms |
4432 KB |
Output is correct |
14 |
Correct |
179 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
4524 KB |
Output is correct |
2 |
Correct |
493 ms |
4576 KB |
Output is correct |
3 |
Correct |
301 ms |
4596 KB |
Output is correct |
4 |
Correct |
260 ms |
4424 KB |
Output is correct |
5 |
Correct |
217 ms |
4432 KB |
Output is correct |
6 |
Correct |
237 ms |
4344 KB |
Output is correct |
7 |
Correct |
226 ms |
4516 KB |
Output is correct |
8 |
Correct |
217 ms |
4432 KB |
Output is correct |
9 |
Correct |
231 ms |
4432 KB |
Output is correct |
10 |
Correct |
233 ms |
4432 KB |
Output is correct |
11 |
Correct |
18 ms |
2392 KB |
Output is correct |
12 |
Correct |
153 ms |
3920 KB |
Output is correct |
13 |
Correct |
176 ms |
4432 KB |
Output is correct |
14 |
Correct |
179 ms |
4308 KB |
Output is correct |
15 |
Correct |
290 ms |
4608 KB |
Output is correct |
16 |
Correct |
227 ms |
4492 KB |
Output is correct |
17 |
Correct |
231 ms |
4692 KB |
Output is correct |
18 |
Correct |
232 ms |
4616 KB |
Output is correct |
19 |
Correct |
228 ms |
4624 KB |
Output is correct |
20 |
Correct |
227 ms |
4620 KB |
Output is correct |
21 |
Correct |
232 ms |
4436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
392 KB |
Output is correct |
3 |
Correct |
1 ms |
532 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
624 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
14 ms |
2652 KB |
Output is correct |
14 |
Correct |
10 ms |
2760 KB |
Output is correct |
15 |
Correct |
9 ms |
2652 KB |
Output is correct |
16 |
Correct |
12 ms |
2652 KB |
Output is correct |
17 |
Correct |
12 ms |
2740 KB |
Output is correct |
18 |
Correct |
17 ms |
2652 KB |
Output is correct |
19 |
Correct |
372 ms |
4524 KB |
Output is correct |
20 |
Correct |
493 ms |
4576 KB |
Output is correct |
21 |
Correct |
301 ms |
4596 KB |
Output is correct |
22 |
Correct |
260 ms |
4424 KB |
Output is correct |
23 |
Correct |
217 ms |
4432 KB |
Output is correct |
24 |
Correct |
237 ms |
4344 KB |
Output is correct |
25 |
Correct |
226 ms |
4516 KB |
Output is correct |
26 |
Correct |
217 ms |
4432 KB |
Output is correct |
27 |
Correct |
231 ms |
4432 KB |
Output is correct |
28 |
Correct |
233 ms |
4432 KB |
Output is correct |
29 |
Correct |
18 ms |
2392 KB |
Output is correct |
30 |
Correct |
153 ms |
3920 KB |
Output is correct |
31 |
Correct |
176 ms |
4432 KB |
Output is correct |
32 |
Correct |
179 ms |
4308 KB |
Output is correct |
33 |
Correct |
290 ms |
4608 KB |
Output is correct |
34 |
Correct |
227 ms |
4492 KB |
Output is correct |
35 |
Correct |
231 ms |
4692 KB |
Output is correct |
36 |
Correct |
232 ms |
4616 KB |
Output is correct |
37 |
Correct |
228 ms |
4624 KB |
Output is correct |
38 |
Correct |
227 ms |
4620 KB |
Output is correct |
39 |
Correct |
232 ms |
4436 KB |
Output is correct |
40 |
Correct |
503 ms |
5460 KB |
Output is correct |
41 |
Correct |
152 ms |
4512 KB |
Output is correct |
42 |
Correct |
263 ms |
5308 KB |
Output is correct |
43 |
Correct |
246 ms |
4932 KB |
Output is correct |
44 |
Correct |
247 ms |
5048 KB |
Output is correct |
45 |
Correct |
552 ms |
8320 KB |
Output is correct |
46 |
Correct |
151 ms |
4948 KB |
Output is correct |
47 |
Correct |
307 ms |
8440 KB |
Output is correct |
48 |
Correct |
291 ms |
6740 KB |
Output is correct |
49 |
Correct |
281 ms |
7440 KB |
Output is correct |