This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC Optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef long double ld;
typedef pair<ll,string>pairls;
#define INF 1000000000000007
#define MOD 1000000007
#define pb push_back
#define fr first
#define sc second
#define endl '\n'
ll n,k,d[200007],f[200007];
int main() {
cin>>n>>k>>k;
for(int i=1;i<=n;i++){
cin>>d[i];
}
for(int i=1;i<=k;i++){
ll x,y;
cin>>x>>y;
f[x]=y;
}
ll l=1;
ll r=0;
ll res=INF;
for(int i=1;i<=n+1;i++){
while(l<r && f[d[l]]<0){
f[d[l]]++;
l++;
}
r=i;
f[d[r]]--;
if(f[d[r]]==0 && r<=n)k--;
if(k==0)res=min(res,r-l+1);
}
if(res==INF)cout<<"impossible"<<endl;
else cout<<res<<endl;
}
Compilation message (stderr)
dna.cpp:1: warning: ignoring '#pragma GCC Optimize' [-Wunknown-pragmas]
1 | #pragma GCC Optimize("O3")
|
# | 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... |