# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1022023 |
2024-07-13T09:05:53 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++14 |
|
83 ms |
6840 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAX_N = 200005;
void solve() {
int n, k, R;
cin >> n >> k >> R;
vector<int>req(k, 0);
int a[n];
for(int i=0; i<n; ++i) cin >> a[i];
for(int i=0; i<R; ++i) {
int b, q;
cin >> b >> q;
req[b] = q;
}
int need = R, l = 0, r = 0, ans = n+1;
vector<int>cnt(k, 0);
++cnt[a[0]];
if(req[a[0]] == 1) --need;
while(r < n) {
while(r != l) {
if((cnt[a[l]]-1) >= req[a[l]]) {
--cnt[a[l]];
++l;
} else break;
}
if(!need) ans = min(ans, r-l+1);
if(r == n-1) break;
++r, ++cnt[a[r]];
if(cnt[a[r]] == req[a[r]]) --need;
}
if(ans == n+1) cout << "impossible" << endl;
else cout << ans << endl;
}
signed main() {
int t = 1;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
432 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 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 |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 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 |
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 |
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 |
20 ms |
1880 KB |
Output is correct |
2 |
Correct |
19 ms |
2380 KB |
Output is correct |
3 |
Correct |
22 ms |
2392 KB |
Output is correct |
4 |
Correct |
19 ms |
2396 KB |
Output is correct |
5 |
Correct |
34 ms |
4404 KB |
Output is correct |
6 |
Correct |
21 ms |
2140 KB |
Output is correct |
7 |
Correct |
22 ms |
2564 KB |
Output is correct |
8 |
Correct |
39 ms |
6232 KB |
Output is correct |
9 |
Correct |
30 ms |
2908 KB |
Output is correct |
10 |
Correct |
19 ms |
2140 KB |
Output is correct |
11 |
Correct |
1 ms |
440 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 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 |
1 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 |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
344 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
3152 KB |
Output is correct |
2 |
Correct |
49 ms |
4436 KB |
Output is correct |
3 |
Correct |
41 ms |
4176 KB |
Output is correct |
4 |
Correct |
24 ms |
2396 KB |
Output is correct |
5 |
Correct |
83 ms |
5716 KB |
Output is correct |
6 |
Correct |
66 ms |
6840 KB |
Output is correct |
7 |
Correct |
33 ms |
2896 KB |
Output is correct |
8 |
Correct |
39 ms |
3408 KB |
Output is correct |
9 |
Correct |
20 ms |
2392 KB |
Output is correct |
10 |
Correct |
19 ms |
2140 KB |
Output is correct |
11 |
Correct |
21 ms |
2396 KB |
Output is correct |
12 |
Correct |
20 ms |
2404 KB |
Output is correct |
13 |
Correct |
34 ms |
4276 KB |
Output is correct |
14 |
Correct |
19 ms |
2140 KB |
Output is correct |
15 |
Correct |
21 ms |
2488 KB |
Output is correct |
16 |
Correct |
38 ms |
6236 KB |
Output is correct |
17 |
Correct |
28 ms |
2908 KB |
Output is correct |
18 |
Correct |
19 ms |
2140 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
452 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |