Submission #660149

#TimeUsernameProblemLanguageResultExecution timeMemory
660149mariaclara Martian DNA (BOI18_dna)C++17
68 / 100
2082 ms12432 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+10; typedef pair<int,int> pii; #define pb push_back #define f first #define s second int n, k, r, a, b, resp = MAXN; vector<int> num[MAXN]; vector<pii> query; int main () { cin >> n >> k >> r; for(int i = 1; i <= n; i++) { cin >> a; num[a].pb(i); } while(r--) { cin >> a >> b; query.pb({a, b}); } for(int i = 1; i <= n; i++) { int fim = 0; for(auto it : query) { auto ptr = lower_bound(num[it.f].begin(), num[it.f].end(), i); ptr += it.s - 1; if(ptr>=num[it.f].end()) { fim = -1; break; } fim = max(fim, *ptr); } if(fim==-1) break; resp = min(resp, fim-i+1); } if(resp == MAXN) cout << "impossible\n"; else cout << resp << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...