# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
709478 | 2023-03-13T16:48:43 Z | stevancv | Martian DNA (BOI18_dna) | C++14 | 202 ms | 141488 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 2e5 + 5; const int inf = 1e9; const int mod = 1e9 + 7; deque<int> dq[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> b(m); for (int i = 0; i < k; i++) { int x; cin >> x >> b[x]; } set<int> s; int dobri = 0; int ans = 1e6; for (int i = 0; i < n; i++) { dq[a[i]].push_back(i); if (dq[a[i]].size() > b[a[i]]) { s.erase(dq[a[i]].front()); dq[a[i]].pop_front(); s.insert(dq[a[i]].front()); } else if (dq[a[i]].size() == b[a[i]]) { s.insert(dq[a[i]].front()); dobri += 1; } if (dobri == k) smin(ans, i - *s.begin() + 1); } if (ans == 1e6) cout << "impossible" << en; else cout << ans << en; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 83 ms | 134860 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 88 ms | 134912 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 137004 KB | Output is correct |
2 | Incorrect | 111 ms | 137580 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 202 ms | 141488 KB | Output is correct |
2 | Incorrect | 185 ms | 141216 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |