# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932575 |
2024-02-23T18:08:58 Z |
imarn |
Martian DNA (BOI18_dna) |
C++14 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=2e5+5;
unordered_map<ll,int>mp,up;
ll a[N];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,k,R;cin>>n>>k>>R;
for(int i=0;i<n;i++)cin>>a[i],mp[a[i]]=0;
for(int i=0;i<R;i++){
ll b,q;cin>>b>>q;up[b]=q;
}int cnt=0;int l=0,ans=1e9;
for(int i=0;i<n;i++){mp[a[i]]++;if(up.find(a[i])!=up.end()&&mp[a[i]]==up[a[i]])cnt++;
while(up.find(a[l])==up.end()||(cnt==R&&mp[a[l]]>up[a[l]]))mp[a[l]]--,l++;
}if(cnt==R)ans=min(ans,i-l+1);
if(ans==1e9)cout<<"impossible";
else cout<<ans;
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:25:28: error: 'i' was not declared in this scope
25 | }if(cnt==R)ans=min(ans,i-l+1);
| ^