Submission #680502

#TimeUsernameProblemLanguageResultExecution timeMemory
680502jhwest2 Martian DNA (BOI18_dna)C++17
100 / 100
237 ms11748 KiB
#include <bits/stdc++.h> using namespace std; const int N = 202020; int n, k, r, a[N]; map<int, int> mp; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> n >> k >> r; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < r; i++) { int x, y; cin >> x >> y; mp[x] = y; } int cnt = r, ans = 1e9; for (int i = 1, j = 1; i <= n; i++) { while (j <= n && cnt) { if (--mp[a[j]] == 0) --cnt; ++j; } if (cnt == 0) ans = min(ans, j - i); if (++mp[a[i]] == 1) ++cnt; } if (ans == 1e9) cout << "impossible"; else cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...