# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946833 | guagua0407 | Lottery (CEOI18_lot) | C++17 | 806 ms | 8788 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.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
int main() {_
int n,l;
cin>>n>>l;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
int q;
cin>>q;
vector<int> qs(q);
vector<int> vec;
for(int i=0;i<q;i++){
cin>>qs[i];
vec.push_back(qs[i]);
}
sort(all(vec));
vec.resize(unique(all(vec))-vec.begin());
vector<vector<int>> ans(n,vector<int>(vec.size()+1));
for(int d=1;d+l-1<n;d++){
int cur=0;
for(int i=0;i<l;i++){
cur+=(a[i]!=a[i+d]);
}
int pos=lower_bound(all(vec),cur)-vec.begin();
ans[0][pos]++;
ans[d][pos]++;
for(int i=1;i+d+l-1<n;i++){
cur-=(a[i-1]!=a[i+d-1]);
cur+=(a[i+l-1]!=a[i+d+l-1]);
int pos=lower_bound(all(vec),cur)-vec.begin();
ans[i][pos]++;
ans[i+d][pos]++;
}
}
for(int i=0;i<n;i++){
for(int j=1;j<vec.size();j++){
ans[i][j]+=ans[i][j-1];
}
}
for(int i=0;i<q;i++){
int pos=lower_bound(all(vec),qs[i])-vec.begin();
for(int j=0;j+l-1<n;j++){
cout<<ans[j][pos]<<' ';
}
cout<<'\n';
}
return 0;
}
//maybe its multiset not set
//yeeorz
//laborz
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... |