Submission #314018

#TimeUsernameProblemLanguageResultExecution timeMemory
314018sofapuden Martian DNA (BOI18_dna)C++14
100 / 100
38 ms2688 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k, r; cin >> n >> k >> r; vector<int> v(n); for(auto &x : v)cin >> x; vector<int> ha(k,0), wa(k,0); for(int i = 0; i < r; ++i){ int a, b; cin >> a >> b; wa[a] = b; } int l = -1, ri = -1, go = 0, best = 1<<30; while(++ri < n){ ha[v[ri]]++; if(ha[v[ri]] == wa[v[ri]])go++; if(go == r){ while(go == r){ ++l; ha[v[l]]--; if(ha[v[l]] == wa[v[l]]-1)go--; } best = min(best,ri-l+1); } } cout << (best == (1<<30) ? "impossible" : to_string(best)) << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...