# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754045 | 2023-06-06T13:59:52 Z | HoriaHaivas | Martian DNA (BOI18_dna) | C++14 | 34 ms | 4680 KB |
/* "TLE is like the wind, always by my side" - Yasuo - 2022 - */ #include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") using namespace std; int need[200001]; bool req[200001]; int f[200001]; int v[200001]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,k,r,i,j,required,pointerdr,pointerst,x,y,mi; bool first; cin >> n >> k >> r; for (i=1; i<=n; i++) { cin >> v[i]; } for (i=1; i<=r; i++) { cin >> x >> y; need[x]=y; req[x]=1; } pointerst=1; pointerdr=1; required=0; mi=n+1; first=true; while (pointerdr<=n) { if (first==false) { f[v[pointerst]]--; if (f[v[pointerst]]==need[v[pointerst]]-1) required--; pointerst++; } first=false; while (required<r && pointerdr<=n) { f[v[pointerdr]]++; if (f[v[pointerdr]]==need[v[pointerdr]]) required++; pointerdr++; } while (required>=r) { f[v[pointerst]]--; if (f[v[pointerst]]==need[v[pointerst]]-1) required--; pointerst++; } pointerst--; f[v[pointerst]]++; if (f[v[pointerst]]==need[v[pointerst]]) required++; if (required==r) mi=min(mi,pointerdr-pointerst); } if (mi!=n+1) cout << mi; else cout << "impossible"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 328 KB | Output is correct |
7 | Correct | 1 ms | 328 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 320 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1492 KB | Output is correct |
2 | Correct | 11 ms | 1492 KB | Output is correct |
3 | Correct | 13 ms | 1492 KB | Output is correct |
4 | Correct | 12 ms | 1516 KB | Output is correct |
5 | Correct | 16 ms | 2640 KB | Output is correct |
6 | Correct | 10 ms | 1444 KB | Output is correct |
7 | Correct | 12 ms | 1616 KB | Output is correct |
8 | Correct | 19 ms | 3124 KB | Output is correct |
9 | Correct | 16 ms | 2092 KB | Output is correct |
10 | Correct | 11 ms | 1440 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 356 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 328 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 328 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 3532 KB | Output is correct |
2 | Correct | 23 ms | 3148 KB | Output is correct |
3 | Correct | 26 ms | 2928 KB | Output is correct |
4 | Correct | 11 ms | 1516 KB | Output is correct |
5 | Correct | 30 ms | 4044 KB | Output is correct |
6 | Correct | 34 ms | 4680 KB | Output is correct |
7 | Correct | 15 ms | 2100 KB | Output is correct |
8 | Correct | 19 ms | 2428 KB | Output is correct |
9 | Correct | 11 ms | 1492 KB | Output is correct |
10 | Correct | 11 ms | 1420 KB | Output is correct |
11 | Correct | 13 ms | 1464 KB | Output is correct |
12 | Correct | 11 ms | 1492 KB | Output is correct |
13 | Correct | 17 ms | 2556 KB | Output is correct |
14 | Correct | 11 ms | 1492 KB | Output is correct |
15 | Correct | 11 ms | 1608 KB | Output is correct |
16 | Correct | 19 ms | 3148 KB | Output is correct |
17 | Correct | 14 ms | 1996 KB | Output is correct |
18 | Correct | 11 ms | 1492 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |