# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482569 | Hazem | Lottery (CEOI18_lot) | C++14 | 2 ms | 460 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>
#define LL long long
using namespace std;
const int N = 1e3+1;
int a[N],val[N][N];
map<int,int>mp;
set<int>st;
vector<int>vals[N];
int main(){
int n,l;
scanf("%d%d",&n,&l);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
st.insert(a[i]);
}
int cnt = 1;
for(auto x:st)
mp[x] = cnt++;
for(int i=1;i<=n;i++)
a[i] = mp[a[i]];
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++){
if(a[i]!=a[j])continue;
int i1 = max(1,i-l+1);
int j1 = j-(i-i1);
if(j1>n-l+1)continue;
vals[j1-i1].push_back(i+1);
// val[i1][j1]++;
// val[i+1][j+1]--;
}
// for(int i=1;i<=n;i++)
// for(int j=1;j<=n;j++)
// val[i][j] += val[i-1][j-1];
for(int i=1;i<=n;i++)
sort(vals[i].begin(),vals[i].end());
int q;
scanf("%d",&q);
while(q--){
int k;
scanf("%d",&k);
for(int i=1;i<=n-l+1;i++){
int ans = 0;
for(int j=1;j<=n-l+1;j++){
if(i==j)continue;
int d = abs(i-j);
int idx = upper_bound(vals[d].begin(),vals[d].end(),min(i,j))-vals[d].begin()-1;
if(l-(vals[d].size()-idx-1)<=k)ans++;
}
printf("%d ",ans);
}
puts("");
}
}
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... |