# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
606781 | ntmp | Martian DNA (BOI18_dna) | C++14 | 291 ms | 11812 KiB |
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<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)
# | 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... |