# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
482572 | Hazem | Lottery (CEOI18_lot) | C++14 | 262 ms | 65540 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 = 1e4+1;
int a[N],val[N][N];
map<int,int>mp;
set<int>st;
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;
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];
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;
if(l-val[min(i,j)][max(i,j)]<=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... |