Submission #526039

#TimeUsernameProblemLanguageResultExecution timeMemory
526039Snowfall Martian DNA (BOI18_dna)C++14
100 / 100
36 ms4440 KiB
#include<bits/stdc++.h> using namespace std; int uck; int arr[200005]; int cn[200005],cur[200005]; main() { int t,q,a; scanf("%d%d%d",&t,&a,&q); uck=q; for(int i = 1;i <= t;i++) { scanf("%d",&arr[i]); } for(int i = 1;i <= q;i++) { int m,n; scanf("%d%d",&m,&n); cn[m]=n; } int st=1,mn=1e9; for(int i = 1;i <= t;i++) { cur[arr[i]]++; if(cur[arr[i]]==cn[arr[i]]) { uck--; } while(uck==0) { mn=min(mn,i-st+1); if(cur[arr[st]]==cn[arr[st]]) { uck++; } cur[arr[st]]--; st++; } } if(mn==1e9) printf("impossible"); else printf("%d",mn); }

Compilation message (stderr)

dna.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
dna.cpp: In function 'int main()':
dna.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d%d",&t,&a,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
dna.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~
dna.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d",&m,&n);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...