Submission #482572

#TimeUsernameProblemLanguageResultExecution timeMemory
482572HazemLottery (CEOI18_lot)C++14
45 / 100
262 ms65540 KiB
#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)

lot.cpp: In function 'int main()':
lot.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d",&n,&l);
      |     ~~~~~^~~~~~~~~~~~~~
lot.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
lot.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
lot.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         scanf("%d",&k);
      |         ~~~~~^~~~~~~~~
#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...