Submission #606781

#TimeUsernameProblemLanguageResultExecution timeMemory
606781ntmp Martian DNA (BOI18_dna)C++14
100 / 100
291 ms11812 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n,k,r; cin>>n>>k>>r; int a[n+1]; map<int,int> mp; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<r;i++) { int x,y; cin>>x>>y; mp[x]=y; } int bad=r; int res=n+1,vt=0,j=0; for(int i=0;i<n;i++) { /*for(int j=vt;j<n;j++) if(bad>0) { //cout<<i<<' '<<j<<endl; mp[a[j]]--; if(mp[a[j]]==0) bad--; } else { cout<<j<<' '<<i<<endl; vt=j; res=min(res,j-i); break; }*/ while(j<n && bad>0) { mp[a[j]]--; if(mp[a[j]]==0) bad--; j++; } if(bad==0) res=min(res,j-i); mp[a[i]]++; if(mp[a[i]]==1) bad++; } if(res==n+1) cout<<"impossible"<<endl; else cout<<res<<endl; }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:18:17: warning: unused variable 'vt' [-Wunused-variable]
   18 |     int res=n+1,vt=0,j=0;
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...