# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003051 | 2024-06-20T04:13:08 Z | daffuwu | Martian DNA (BOI18_dna) | C++14 | 26 ms | 3932 KB |
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, k, r, b, q, cnt[200069], d[200069], cvio, ans = 1e9; void chg(int x, int y) { int prev = cnt[x]; cnt[x] += y; if (prev == -1 && cnt[x] == 0) cvio--; else if (prev == 0 && cnt[x] == -1) cvio++; } int main() { int i, j; scanf("%d%d%d", &n, &k, &r); for (i=1; i<=n; i++) scanf("%d", d+i); for (i=1; i<=r; i++) { scanf("%d%d", &b, &q); cnt[b] = -q; cvio++; } for (i=1, j=1; i<=n; i++) { chg(d[i], 1); for (; j<i && cvio == 0; chg(d[j++], -1)); for (;j>1 && cvio>0; chg(d[--j], 1)); if (cvio == 0) ans = min(ans, i-j+1); } if (ans == 1e9) printf("impossible\n"); else printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 396 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 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 | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 452 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 604 KB | Output is correct |
14 | Correct | 0 ms | 448 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1368 KB | Output is correct |
2 | Correct | 12 ms | 1616 KB | Output is correct |
3 | Correct | 13 ms | 1592 KB | Output is correct |
4 | Correct | 11 ms | 1632 KB | Output is correct |
5 | Correct | 14 ms | 2644 KB | Output is correct |
6 | Correct | 10 ms | 1368 KB | Output is correct |
7 | Correct | 10 ms | 1628 KB | Output is correct |
8 | Correct | 15 ms | 3160 KB | Output is correct |
9 | Correct | 13 ms | 2136 KB | Output is correct |
10 | Correct | 11 ms | 1372 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 360 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 444 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 | 432 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 444 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 3128 KB | Output is correct |
2 | Correct | 20 ms | 2900 KB | Output is correct |
3 | Correct | 17 ms | 2716 KB | Output is correct |
4 | Correct | 11 ms | 1616 KB | Output is correct |
5 | Correct | 22 ms | 3676 KB | Output is correct |
6 | Correct | 26 ms | 3932 KB | Output is correct |
7 | Correct | 15 ms | 2140 KB | Output is correct |
8 | Correct | 16 ms | 2396 KB | Output is correct |
9 | Correct | 14 ms | 1372 KB | Output is correct |
10 | Correct | 12 ms | 1368 KB | Output is correct |
11 | Correct | 13 ms | 1628 KB | Output is correct |
12 | Correct | 12 ms | 1628 KB | Output is correct |
13 | Correct | 14 ms | 2652 KB | Output is correct |
14 | Correct | 14 ms | 1368 KB | Output is correct |
15 | Correct | 10 ms | 1656 KB | Output is correct |
16 | Correct | 15 ms | 3164 KB | Output is correct |
17 | Correct | 13 ms | 2140 KB | Output is correct |
18 | Correct | 11 ms | 1372 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 | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 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 | 1 ms | 604 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 |