# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
397387 |
2021-05-02T02:17:22 Z |
KoD |
Martian DNA (BOI18_dna) |
C++17 |
|
142 ms |
13996 KB |
#include <bits/stdc++.h>
template <class T>
using Vec = std::vector<T>;
int main() {
int N, K, R;
std::cin >> N >> K >> R;
Vec<int> A(N);
for (auto& x: A) {
std::cin >> x;
}
Vec<Vec<int>> pos(K);
for (int i = 0; i < N; ++i) {
pos[A[i]].push_back(i);
}
Vec<int> need(K);
while (R--) {
int b;
std::cin >> b;
std::cin >> need[b];
}
int right = 0;
for (int i = 0; i < K; ++i) {
if (need[i] == 0) {
continue;
}
if (need[i] > (int) pos[i].size()) {
std::cout << "impossible\n";
return 0;
}
right = std::max(right, pos[i][need[i] - 1]);
}
int ans = right + 1;
for (int left = 1; left < N; ++left) {
const auto x = A[left - 1];
if (need[x] > 0) {
need[x] += 1;
if (need[x] > (int) pos[x].size()) {
break;
}
right = std::max(right, pos[x][need[x] - 1]);
}
ans = std::min(ans, right - left + 1);
}
std::cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
2 ms |
464 KB |
Output is correct |
5 |
Correct |
2 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2692 KB |
Output is correct |
2 |
Correct |
39 ms |
2748 KB |
Output is correct |
3 |
Correct |
39 ms |
2536 KB |
Output is correct |
4 |
Correct |
38 ms |
2724 KB |
Output is correct |
5 |
Correct |
80 ms |
7068 KB |
Output is correct |
6 |
Correct |
36 ms |
2600 KB |
Output is correct |
7 |
Correct |
43 ms |
2572 KB |
Output is correct |
8 |
Correct |
98 ms |
13996 KB |
Output is correct |
9 |
Correct |
68 ms |
3496 KB |
Output is correct |
10 |
Correct |
38 ms |
2628 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
304 KB |
Output is correct |
13 |
Correct |
2 ms |
460 KB |
Output is correct |
14 |
Correct |
2 ms |
560 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
7420 KB |
Output is correct |
2 |
Correct |
111 ms |
6312 KB |
Output is correct |
3 |
Correct |
85 ms |
5956 KB |
Output is correct |
4 |
Correct |
39 ms |
2596 KB |
Output is correct |
5 |
Correct |
131 ms |
9080 KB |
Output is correct |
6 |
Correct |
142 ms |
13652 KB |
Output is correct |
7 |
Correct |
65 ms |
3652 KB |
Output is correct |
8 |
Correct |
91 ms |
4392 KB |
Output is correct |
9 |
Correct |
37 ms |
2700 KB |
Output is correct |
10 |
Correct |
40 ms |
2732 KB |
Output is correct |
11 |
Correct |
39 ms |
2520 KB |
Output is correct |
12 |
Correct |
38 ms |
2760 KB |
Output is correct |
13 |
Correct |
75 ms |
6980 KB |
Output is correct |
14 |
Correct |
37 ms |
2604 KB |
Output is correct |
15 |
Correct |
43 ms |
2600 KB |
Output is correct |
16 |
Correct |
109 ms |
13992 KB |
Output is correct |
17 |
Correct |
63 ms |
3492 KB |
Output is correct |
18 |
Correct |
38 ms |
2604 KB |
Output is correct |
19 |
Correct |
2 ms |
296 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
2 ms |
460 KB |
Output is correct |
22 |
Correct |
2 ms |
564 KB |
Output is correct |
23 |
Correct |
2 ms |
308 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |