# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013879 |
2024-07-04T07:17:56 Z |
SulA |
Martian DNA (BOI18_dna) |
C++17 |
|
24 ms |
4664 KB |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int n,k,q; cin >> n >> k >> q;
int a[n], target[k] = {}, frq[k] = {};
for (int& i : a) {
cin >> i;
frq[i]++;
}
while (q--) {
int x, y; cin >> x >> y;
target[x] = y;
}
for (int val = 0; val < k; val++) {
if (target[val] > frq[val]) {
cout << "impossible";
return 0;
} else {
frq[val] = 0;
}
}
int cnt = count(target, target + k, 0);
int l = 0, r = -1;
int ans = n;
while (++r < n) {
if (++frq[a[r]] == target[a[r]]) cnt++;
if (cnt == k) {
while (cnt == k) {
if (--frq[a[l]] < target[a[l]]) {
cnt--;
}
l++;
}
ans = min(ans, r-(l-1)+1);
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
456 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
452 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1600 KB |
Output is correct |
2 |
Correct |
8 ms |
1372 KB |
Output is correct |
3 |
Correct |
9 ms |
1668 KB |
Output is correct |
4 |
Correct |
8 ms |
1628 KB |
Output is correct |
5 |
Correct |
12 ms |
2996 KB |
Output is correct |
6 |
Correct |
8 ms |
1372 KB |
Output is correct |
7 |
Correct |
8 ms |
1624 KB |
Output is correct |
8 |
Correct |
14 ms |
3932 KB |
Output is correct |
9 |
Correct |
10 ms |
2176 KB |
Output is correct |
10 |
Correct |
8 ms |
1488 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
600 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
452 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
3420 KB |
Output is correct |
2 |
Correct |
17 ms |
3160 KB |
Output is correct |
3 |
Correct |
14 ms |
2908 KB |
Output is correct |
4 |
Correct |
8 ms |
1624 KB |
Output is correct |
5 |
Correct |
20 ms |
4048 KB |
Output is correct |
6 |
Correct |
23 ms |
4664 KB |
Output is correct |
7 |
Correct |
11 ms |
2140 KB |
Output is correct |
8 |
Correct |
13 ms |
2504 KB |
Output is correct |
9 |
Correct |
8 ms |
1628 KB |
Output is correct |
10 |
Correct |
8 ms |
1624 KB |
Output is correct |
11 |
Correct |
9 ms |
1464 KB |
Output is correct |
12 |
Correct |
8 ms |
1628 KB |
Output is correct |
13 |
Correct |
12 ms |
2988 KB |
Output is correct |
14 |
Correct |
7 ms |
1372 KB |
Output is correct |
15 |
Correct |
8 ms |
1628 KB |
Output is correct |
16 |
Correct |
14 ms |
4060 KB |
Output is correct |
17 |
Correct |
10 ms |
2136 KB |
Output is correct |
18 |
Correct |
9 ms |
1628 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
464 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
500 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |