Submission #789467

#TimeUsernameProblemLanguageResultExecution timeMemory
789467Trisanu_Das Martian DNA (BOI18_dna)C++17
100 / 100
76 ms4580 KiB
#include <bits/stdc++.h> using namespace std; long long n, k, cnt, x, a[200010], b[200010], c[200010], l = 1, r, minn = 1e18; int main() { cin >> n >> k >> cnt; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= cnt; i++) { cin >> x; cin >> b[x]; } while (r <= n) { if (cnt) { r++; c[a[r]]++; if (c[a[r]] == b[a[r]]) cnt--; } else { minn = min(minn,r-l+1); if (c[a[l]] == b[a[l]]) cnt++; c[a[l]]--; l++; } } if (minn == 1e18) cout << "impossible" << endl; else cout << minn << 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...