# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
971625 |
2024-04-29T05:22:53 Z |
Baytoro |
Lottery (CEOI18_lot) |
C++17 |
|
571 ms |
8276 KB |
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
const int N=1e4+6;
int a[N],ans[N][101];
void solve(){
int n,l;
cin>>n>>l;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int q;cin>>q;
vector<pair<int,int> > v(q);
vector<int> sv(q);
for(int i=0;i<q;i++){
cin>>v[i].fr;
sv[i]=v[i].fr;
v[i].sc=i;
}
sort(v.begin(),v.end());
int last=0;
vector<int> id(l+1);
for(int i=0;i<=l;i++){
while(last<q && v[last].fr<i){
last++;
}
id[i]=last;
}
for(int i=1;i<=n-l;i++){
int diff=0;
for(int j=1;j<=l;j++){
if(a[j]!=a[i+j]) diff++;
}
if(diff<=v.back().fr){
ans[i+1][id[diff]]++;
ans[1][id[diff]]++;
}
for(int j=2;j+i<=n-l+1;j++){
if(a[j-1]!=a[j+i-1]) diff--;
if(a[j+l-1]!=a[j+i+l-1]) diff++;
if(diff<=v.back().fr){
ans[j][id[diff]]++;
ans[i+j][id[diff]]++;
}
}
}
for(int i=1;i<=n-l+1;i++)
for(int j=1;j<q;j++)
ans[i][j]+=ans[i][j-1];
for(int i=0;i<q;i++){
for(int j=1;j<=n-l+1;j++) cout<<ans[j][id[sv[i]]]<<' ';
cout<<endl;
}
}
signed main(){
int t=1;//cin>>t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
9 ms |
2652 KB |
Output is correct |
14 |
Correct |
6 ms |
2652 KB |
Output is correct |
15 |
Correct |
4 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
5 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
299 ms |
4424 KB |
Output is correct |
2 |
Correct |
441 ms |
4440 KB |
Output is correct |
3 |
Correct |
111 ms |
4440 KB |
Output is correct |
4 |
Correct |
71 ms |
4176 KB |
Output is correct |
5 |
Correct |
42 ms |
2624 KB |
Output is correct |
6 |
Correct |
62 ms |
2896 KB |
Output is correct |
7 |
Correct |
85 ms |
2820 KB |
Output is correct |
8 |
Correct |
95 ms |
3348 KB |
Output is correct |
9 |
Correct |
70 ms |
4436 KB |
Output is correct |
10 |
Correct |
80 ms |
4184 KB |
Output is correct |
11 |
Correct |
8 ms |
2396 KB |
Output is correct |
12 |
Correct |
53 ms |
2532 KB |
Output is correct |
13 |
Correct |
46 ms |
2384 KB |
Output is correct |
14 |
Correct |
54 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
299 ms |
4424 KB |
Output is correct |
2 |
Correct |
441 ms |
4440 KB |
Output is correct |
3 |
Correct |
111 ms |
4440 KB |
Output is correct |
4 |
Correct |
71 ms |
4176 KB |
Output is correct |
5 |
Correct |
42 ms |
2624 KB |
Output is correct |
6 |
Correct |
62 ms |
2896 KB |
Output is correct |
7 |
Correct |
85 ms |
2820 KB |
Output is correct |
8 |
Correct |
95 ms |
3348 KB |
Output is correct |
9 |
Correct |
70 ms |
4436 KB |
Output is correct |
10 |
Correct |
80 ms |
4184 KB |
Output is correct |
11 |
Correct |
8 ms |
2396 KB |
Output is correct |
12 |
Correct |
53 ms |
2532 KB |
Output is correct |
13 |
Correct |
46 ms |
2384 KB |
Output is correct |
14 |
Correct |
54 ms |
2384 KB |
Output is correct |
15 |
Correct |
182 ms |
4188 KB |
Output is correct |
16 |
Correct |
61 ms |
3164 KB |
Output is correct |
17 |
Correct |
102 ms |
4368 KB |
Output is correct |
18 |
Correct |
65 ms |
3408 KB |
Output is correct |
19 |
Correct |
65 ms |
3552 KB |
Output is correct |
20 |
Correct |
65 ms |
4464 KB |
Output is correct |
21 |
Correct |
66 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
9 ms |
2652 KB |
Output is correct |
14 |
Correct |
6 ms |
2652 KB |
Output is correct |
15 |
Correct |
4 ms |
2652 KB |
Output is correct |
16 |
Correct |
6 ms |
2652 KB |
Output is correct |
17 |
Correct |
5 ms |
2648 KB |
Output is correct |
18 |
Correct |
5 ms |
2652 KB |
Output is correct |
19 |
Correct |
299 ms |
4424 KB |
Output is correct |
20 |
Correct |
441 ms |
4440 KB |
Output is correct |
21 |
Correct |
111 ms |
4440 KB |
Output is correct |
22 |
Correct |
71 ms |
4176 KB |
Output is correct |
23 |
Correct |
42 ms |
2624 KB |
Output is correct |
24 |
Correct |
62 ms |
2896 KB |
Output is correct |
25 |
Correct |
85 ms |
2820 KB |
Output is correct |
26 |
Correct |
95 ms |
3348 KB |
Output is correct |
27 |
Correct |
70 ms |
4436 KB |
Output is correct |
28 |
Correct |
80 ms |
4184 KB |
Output is correct |
29 |
Correct |
8 ms |
2396 KB |
Output is correct |
30 |
Correct |
53 ms |
2532 KB |
Output is correct |
31 |
Correct |
46 ms |
2384 KB |
Output is correct |
32 |
Correct |
54 ms |
2384 KB |
Output is correct |
33 |
Correct |
182 ms |
4188 KB |
Output is correct |
34 |
Correct |
61 ms |
3164 KB |
Output is correct |
35 |
Correct |
102 ms |
4368 KB |
Output is correct |
36 |
Correct |
65 ms |
3408 KB |
Output is correct |
37 |
Correct |
65 ms |
3552 KB |
Output is correct |
38 |
Correct |
65 ms |
4464 KB |
Output is correct |
39 |
Correct |
66 ms |
4188 KB |
Output is correct |
40 |
Correct |
518 ms |
5152 KB |
Output is correct |
41 |
Correct |
13 ms |
2652 KB |
Output is correct |
42 |
Correct |
98 ms |
5168 KB |
Output is correct |
43 |
Correct |
75 ms |
4580 KB |
Output is correct |
44 |
Correct |
73 ms |
4692 KB |
Output is correct |
45 |
Correct |
571 ms |
8240 KB |
Output is correct |
46 |
Correct |
19 ms |
2908 KB |
Output is correct |
47 |
Correct |
263 ms |
8276 KB |
Output is correct |
48 |
Correct |
128 ms |
6448 KB |
Output is correct |
49 |
Correct |
122 ms |
7024 KB |
Output is correct |