Submission #530256

#TimeUsernameProblemLanguageResultExecution timeMemory
530256kderylo Martian DNA (BOI18_dna)C++17
100 / 100
37 ms3908 KiB
#include <iostream> using namespace std; const int stala=2e5+10; int tab[stala]; int zapalone[stala]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ile,rozmiar,ile_zapalonych; cin>>ile>>rozmiar>>ile_zapalonych; for(int i=1;i<=ile;i++) { cin>>tab[i]; } for(int i=1;i<=ile_zapalonych;i++) { int podstawa,ilosc; cin>>podstawa>>ilosc; zapalone[podstawa]=ilosc; } int ind=0; int wyn=1e9; for(int i=1;i<=ile;i++) { while(ile_zapalonych>0&&ind<ile) { ind++; zapalone[tab[ind]]--; if(zapalone[tab[ind]]==0) { ile_zapalonych--; } } if(ile_zapalonych==0) { wyn=min(wyn,ind-i+1); } zapalone[tab[i]]++; if(zapalone[tab[i]]==1) { ile_zapalonych++; } } if(wyn==1e9) { cout<<"impossible"; } else { cout<<wyn; } 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...