Submission #1123739

#TimeUsernameProblemLanguageResultExecution timeMemory
1123739sigmaohiogyattrip Martian DNA (BOI18_dna)C++17
40 / 100
2093 ms3600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pll pair<ll,ll> #define qll queue<ll> #define inf LLONG_MAX #define test return 12; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,k,r;cin>>n>>k>>r; ll c[n]; qll q; for(ll i=0;i<n;i++) { c[i];cin>>c[i]; } ll cnt[k],req[k]; fill(req,req+k,0); fill(cnt,cnt+k,0); for(ll i=0;i<r;i++) { ll a,b;cin>>a>>b; req[a]=b; } long long mean = LLONG_MAX; for(ll i=0;i<n;i++){ q.push(c[i]); cnt[c[i]]++; bool flag=false; for(ll j=0;j<k;j++){ if(cnt[j]<req[j])flag=true; // error here } if(!flag){ while(cnt[q.front()]-1>=req[q.front()]){ cnt[q.front()]--; q.pop(); } } if(!flag && q.size()<mean){ mean=q.size(); } } if (mean==inf){ cout<<"impossible"; return 0; } cout<<mean; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...