제출 #1310418

#제출 시각아이디문제언어결과실행 시간메모리
1310418kamal618 Martian DNA (BOI18_dna)C++20
40 / 100
2096 ms11872 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]; 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.clear(); for(ll j=i; j<n; j++) { mp[a[j]]++; for(auto i:mp1) { if(mp[i.first]>=i.second) { b=1; } else { b=0; break; } } if(b)ans=min(ans,j-i); } } 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...