#include <bits/stdc++.h>
#define MAX 11000
int ans[MAX][155];
int valores[155];
int difs=0;
int addval(int u){
int l=0,r=difs-1;
while(l<r){
int m = (l+r)/2;
if(valores[m]>=u){
r=m;
}else l=m+1;
}
return l;
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int N,L;
std::cin>>N>>L;
int array[N];
for(auto&x:array)std::cin>>x;
int Q;
std::cin>>Q;
std::vector<int> vec;
std::map<int,int> mapa;
int cur=0;
std::vector<int> v;v.push_back(0);v.push_back(1e9);
for(int i=0;i!=Q;++i){
int x;
std::cin>>x;
v.push_back(x);
vec.push_back(x);
}
std::sort(v.begin(),v.end());
for(auto&x:v){
if(mapa.find(x)==mapa.end()){
valores[cur]=x;
mapa[x]=cur;
++cur;
++difs;
}
}
for(int j=1;j!=N;++j){
if(j+L>N)break;
int count=0;
int cur1=0,cur2=j;
for(int i=0;i!=L;++i){
count+=(array[cur1]!=array[cur2]);
++cur1;
++cur2;
}
assert(cur2<=N&&cur1<=N);
{
int k = addval(count);
ans[cur1-L][k]++;
ans[cur2-L][k]++;
}
while(cur2!=N){
count-=(array[cur1-L]!=array[cur2-L]);
count+=(array[cur1]!=array[cur2]);
++cur1;++cur2;
{
int k = addval(count);
ans[cur1-L][k]++;
ans[cur2-L][k]++;
}
}
}
for(int i=0;i!=N;++i){
int sum=0;
for(int j=0;j!=104;++j){
sum+=ans[i][j];
ans[i][j]=sum;
}
}
for(auto&x:vec){
for(int i=0;i<N-L+1;++i){
std::cout<<ans[i][mapa[x]]<<" ";
}
std::cout<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
18 ms |
1536 KB |
Output is correct |
14 |
Correct |
12 ms |
1540 KB |
Output is correct |
15 |
Correct |
9 ms |
1500 KB |
Output is correct |
16 |
Correct |
17 ms |
1552 KB |
Output is correct |
17 |
Correct |
16 ms |
1604 KB |
Output is correct |
18 |
Correct |
16 ms |
1604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
375 ms |
6400 KB |
Output is correct |
2 |
Correct |
319 ms |
6416 KB |
Output is correct |
3 |
Correct |
306 ms |
6436 KB |
Output is correct |
4 |
Correct |
295 ms |
6468 KB |
Output is correct |
5 |
Correct |
95 ms |
6468 KB |
Output is correct |
6 |
Correct |
275 ms |
6464 KB |
Output is correct |
7 |
Correct |
76 ms |
6416 KB |
Output is correct |
8 |
Correct |
144 ms |
6480 KB |
Output is correct |
9 |
Correct |
303 ms |
6420 KB |
Output is correct |
10 |
Correct |
294 ms |
6500 KB |
Output is correct |
11 |
Correct |
14 ms |
2056 KB |
Output is correct |
12 |
Correct |
157 ms |
5792 KB |
Output is correct |
13 |
Correct |
122 ms |
6468 KB |
Output is correct |
14 |
Correct |
120 ms |
6448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
375 ms |
6400 KB |
Output is correct |
2 |
Correct |
319 ms |
6416 KB |
Output is correct |
3 |
Correct |
306 ms |
6436 KB |
Output is correct |
4 |
Correct |
295 ms |
6468 KB |
Output is correct |
5 |
Correct |
95 ms |
6468 KB |
Output is correct |
6 |
Correct |
275 ms |
6464 KB |
Output is correct |
7 |
Correct |
76 ms |
6416 KB |
Output is correct |
8 |
Correct |
144 ms |
6480 KB |
Output is correct |
9 |
Correct |
303 ms |
6420 KB |
Output is correct |
10 |
Correct |
294 ms |
6500 KB |
Output is correct |
11 |
Correct |
14 ms |
2056 KB |
Output is correct |
12 |
Correct |
157 ms |
5792 KB |
Output is correct |
13 |
Correct |
122 ms |
6468 KB |
Output is correct |
14 |
Correct |
120 ms |
6448 KB |
Output is correct |
15 |
Correct |
328 ms |
6492 KB |
Output is correct |
16 |
Correct |
259 ms |
6404 KB |
Output is correct |
17 |
Correct |
327 ms |
6504 KB |
Output is correct |
18 |
Correct |
308 ms |
6432 KB |
Output is correct |
19 |
Correct |
312 ms |
6444 KB |
Output is correct |
20 |
Correct |
311 ms |
6464 KB |
Output is correct |
21 |
Correct |
313 ms |
6448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
324 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
18 ms |
1536 KB |
Output is correct |
14 |
Correct |
12 ms |
1540 KB |
Output is correct |
15 |
Correct |
9 ms |
1500 KB |
Output is correct |
16 |
Correct |
17 ms |
1552 KB |
Output is correct |
17 |
Correct |
16 ms |
1604 KB |
Output is correct |
18 |
Correct |
16 ms |
1604 KB |
Output is correct |
19 |
Correct |
375 ms |
6400 KB |
Output is correct |
20 |
Correct |
319 ms |
6416 KB |
Output is correct |
21 |
Correct |
306 ms |
6436 KB |
Output is correct |
22 |
Correct |
295 ms |
6468 KB |
Output is correct |
23 |
Correct |
95 ms |
6468 KB |
Output is correct |
24 |
Correct |
275 ms |
6464 KB |
Output is correct |
25 |
Correct |
76 ms |
6416 KB |
Output is correct |
26 |
Correct |
144 ms |
6480 KB |
Output is correct |
27 |
Correct |
303 ms |
6420 KB |
Output is correct |
28 |
Correct |
294 ms |
6500 KB |
Output is correct |
29 |
Correct |
14 ms |
2056 KB |
Output is correct |
30 |
Correct |
157 ms |
5792 KB |
Output is correct |
31 |
Correct |
122 ms |
6468 KB |
Output is correct |
32 |
Correct |
120 ms |
6448 KB |
Output is correct |
33 |
Correct |
328 ms |
6492 KB |
Output is correct |
34 |
Correct |
259 ms |
6404 KB |
Output is correct |
35 |
Correct |
327 ms |
6504 KB |
Output is correct |
36 |
Correct |
308 ms |
6432 KB |
Output is correct |
37 |
Correct |
312 ms |
6444 KB |
Output is correct |
38 |
Correct |
311 ms |
6464 KB |
Output is correct |
39 |
Correct |
313 ms |
6448 KB |
Output is correct |
40 |
Correct |
547 ms |
7132 KB |
Output is correct |
41 |
Correct |
18 ms |
6452 KB |
Output is correct |
42 |
Correct |
449 ms |
7128 KB |
Output is correct |
43 |
Correct |
429 ms |
6876 KB |
Output is correct |
44 |
Correct |
426 ms |
7104 KB |
Output is correct |
45 |
Correct |
978 ms |
10260 KB |
Output is correct |
46 |
Correct |
24 ms |
6724 KB |
Output is correct |
47 |
Correct |
658 ms |
10332 KB |
Output is correct |
48 |
Correct |
574 ms |
8548 KB |
Output is correct |
49 |
Correct |
582 ms |
9284 KB |
Output is correct |