제출 #1310433

#제출 시각아이디문제언어결과실행 시간메모리
1310433kamal618 Martian DNA (BOI18_dna)C++20
68 / 100
2094 ms4424 KiB
#include<bits/stdc++.h> #define endl "\n" using namespace std ; typedef long long ll; typedef long double ld ; #define pb push_back #define pp pop_back const int N=1e6+9; const ll inf=1e18 ; const ll mod = 1e9+9 ; #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll n,k,q,cnt[N],freq[N],freq1[N],x[N],y[N],a[N],l,r; map<ll,ll>mp1; map<ll,ll>mp; bool b=0; int main() { fast; ll ans=inf; cin>>n>>k>>q; for(int i=0; i<n; i++){ cin>>a[i]; } for(ll i=0;i<q;i++){ cin>>x[i]>>y[i]; freq1[x[i]]+=y[i]; } for(ll i=0; i<n; i++){ freq[a[i]]++; b=1; for(ll j=0;j<q;j++){ if(freq[x[j]]>=y[j]){ b=1; } else{ b=0; break; } } while(freq[a[l]]>freq1[a[l]]) { freq[a[l]]--; l++; } if(b)ans=min(ans,i-l); } if(ans==inf)cout<<"impossible"; else cout<<ans+1; 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...