Submission #483338

#TimeUsernameProblemLanguageResultExecution timeMemory
483338MOUF_MAHMALATLottery (CEOI18_lot)C++14
45 / 100
3078 ms600 KiB
#include<bits/stdc++.h> #define all(s) s.begin(),s.end() #define F first #define S second using namespace std; typedef int ll; const ll mod=1e9+7; ll n,l,q,o,a[10001],c[10001],x,ans,sz[10001]; map<ll,ll>mp; vector<vector<ll> >v; int main() { scanf("%d%d",&n,&l); for(ll i=0; i<n; i++) { scanf("%d",&a[i]); if(!mp[a[i]]) mp[a[i]]=++o; a[i]=mp[a[i]]; } mp.clear(); v.resize(o+1); for(ll i=0; i<n; i++) v[a[i]].push_back(i),sz[a[i]]++; scanf("%d",&q); while(q--) { scanf("%d",&x); x=l-x; for(ll i=0; i+l-1<n; i++) { ans=0; memset(c,0,sizeof c); for(ll j=i; j<i+l; j++) for(ll k=0; k<sz[a[j]]; k++) { if(v[a[j]][k]-j+i>=0) c[v[a[j]][k]-j+i]++; } for(ll j=0; j+l-1<n; j++) if(i!=j) ans+=(c[j]>=x); printf("%d ",ans); } printf("\n"); } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d",&n,&l);
      |     ~~~~~^~~~~~~~~~~~~~
lot.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
lot.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
lot.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...