Submission #329908

#TimeUsernameProblemLanguageResultExecution timeMemory
329908nandonathaniel Martian DNA (BOI18_dna)C++14
0 / 100
20 ms2796 KiB
#include<bits/stdc++.h> using namespace std; int mini[10],skg[10]; int s[200005]; bool check(){ for(int i=0;i<10;i++){ if(skg[i]<mini[i])return false; } return true; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n,k,r,x,y; cin >> n >> k >> r; for(int i=0;i<n;i++)cin >> s[i]; for(int i=1;i<=r;i++){ cin >> x >> y; mini[x]=y; } int ans=n+1; int awal=0,akhir=0; skg[s[0]]++; while(awal<=akhir && akhir<n){ bool stat=check(); if(!stat){ if(akhir<n-1){ akhir++; skg[s[akhir]]++; } else break; } else{ ans=min(ans,akhir-awal+1); skg[s[awal]]--; awal++; } } if(ans==n+1)cout << "impossible\n"; else cout << ans << '\n'; return 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...