Submission #311468

#TimeUsernameProblemLanguageResultExecution timeMemory
311468OttoTheDino Martian DNA (BOI18_dna)C++17
100 / 100
41 ms4624 KiB
#include <bits/stdc++.h> using namespace std; #define rep(n) for (int i = 0; i < n; ++i) #define rep2(n) for (int j = 0; j < n; ++j) #define mp make_pair #define pb push_back typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k, r; cin >> n >> k >> r; int d[n], cnt[k] = {}, mst[k] = {}, b, q, cur = 0, start = 0, ans = INT_MAX; rep (n) cin >> d[i]; rep (r) { cin >> b >> q; mst[b] = q; } rep (n) { cnt[d[i]]++; if (cnt[d[i]]==mst[d[i]]) cur++; while (cur==r) { ans = min(ans, i-start+1); if (cnt[d[start]]==mst[d[start]]) cur--; cnt[d[start++]]--; } } if (ans!=INT_MAX) cout << ans << "\n"; else cout << "impossible\n"; 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...