# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126005 | Hassoony | Lottery (CEOI18_lot) | C++17 | 814 ms | 8696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10009;
int n,l,a[MX],id[109];
pair<int,int> k[109];
int ans[MX][109];
int col[MX],p[MX];
int where[MX],ans1[MX][109],q;
int main(){
cin>>n>>l;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
cin>>q;
for(int i=1;i<=q;i++){
scanf("%d",&k[i].first);
k[i].second=i;
}
for(int i=0;i<=l;i++)where[i]=q+1;
sort(k+1,k+1+q);
for(int i=1;i<=q;i++){
id[k[i].second]=i;
}
for(int i=0;i<=l;i++){
for(int j=1;j<=q;j++){
if(k[j].first>=i){
where[i]=j;
break;
}
}
}
for(int j=1;j<=(n-l+1);j++){
for(int i=1;i<MX;i++)col[i]=p[i]=0;
for(int i=1;i+j<=n;i++){
col[i]=(a[i]!=a[i+j]);
p[i]=p[i-1]+col[i];
}
for(int i=1;i+j+l-1<=n;i++){
ans[i][where[p[i+l-1]-p[i-1]]]++;
ans[i+j][where[p[i+l-1]-p[i-1]]]++;
}
}
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=1;i<=q;i++){
for(int j=1;j<=n-l+1;j++)cout<<ans[j][id[i]]<<" ";
puts("");
}
}
/*
6 2
1 2 1 3 2 1
2
1
2
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |