This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |