# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651084 | 2022-10-17T01:40:53 Z | dooompy | Martian DNA (BOI18_dna) | C++17 | 367 ms | 15348 KB |
#include <bits/stdc++.h> using namespace std; int states[200005]; map<int, pair<int, int>> req; set<int> completed; map<int, int> have; int n, k, r; bool move(int &idx) { if (completed.size() == r) return true; while (completed.size() < r) { idx++; if (idx > n) return false; have[states[idx]]++; if (have[states[idx]] == req[states[idx]].first) { completed.insert(req[states[idx]].second); } } return true; } int main() { cin >> n >> k >> r; for (int i = 1; i <= n; i++) cin >> states[i]; for (int i = 0; i < r; i++) { int b, q; cin >> b >> q; req[b] = {q, i}; } int idx = 0; bool able = move(idx); if (!able) { cout << "impossible"; return 0; } int l = 1; int ans = (idx - l + 1); // cout << l << " " << idx << endl; while (l < n) { if (req[states[l]].first == have[states[idx]]) { completed.erase(req[states[idx]].second); } have[states[idx]]--; l++; able = move(idx); if (!able) break; ans = min(ans, idx - l + 1); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 31 ms | 1348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 367 ms | 15348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |