Submission #1033064

#TimeUsernameProblemLanguageResultExecution timeMemory
1033064vannnnnnnn Martian DNA (BOI18_dna)C++14
68 / 100
2032 ms3932 KiB
#include<bits/stdc++.h> using namespace std; int note[200005], lst[200005], mp[200005], a[200005]; int main() { int n, k, r, ans=1e9; scanf("%d %d %d", &n, &k, &r); for(int i=1; i<=n; i++) { scanf("%d", &a[i]); } for(int i=1; i<=r; i++) { int c, d; scanf("%d %d", &c, &d); note[c]=d; lst[i]=c; } int start=1; for(int i=1; i<=n; i++) { mp[a[i]]++; int find=1; for(int j=1; j<=r; j++) { if(mp[lst[j]]<note[lst[j]]) { find=0; break; } } if(find==1) { while(start<i) { if(mp[a[start]]-1>=note[a[start]]) { mp[a[start]]--; start++; } else { break; } } ans=min(ans, i-start+1); } } if(ans==1e9)printf("impossible\n"); else printf("%d\n", ans); }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d %d %d", &n, &k, &r);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
dna.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d %d", &c, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...