제출 #1310421

#제출 시각아이디문제언어결과실행 시간메모리
1310421kamal618 Martian DNA (BOI18_dna)C++20
0 / 100
2095 ms11904 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],x,y,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]; } while(q--){ cin>>x>>y; mp1[x]+=y; } for(ll i=0; i<n; i++){ mp[a[i]]++; for(auto i:mp1){ if(mp[i.first]>=i.second){ b=1; } else{ b=0; break; } } while(mp[a[l]]>mp1[a[l]]){ l++; mp[a[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...