# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
653705 |
2022-10-27T18:13:52 Z |
Juan |
Martian DNA (BOI18_dna) |
C++14 |
|
310 ms |
10504 KB |
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
#define pii pair<int, int>
#define ll long long
int v[maxn], need[maxn];
map<int, int> mp;
int main(){
int n, k, m; cin >> n >> k >> m;
for(int i = 0; i < n; i++) cin >> v[i];
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
need[a] = b;
}
int l = 0, r = 0;
int ans = n+1, invalid_cnt = m;
while(l<n){
bool term = false;
while(invalid_cnt){
if(r==n) {term = true; break;}
mp[v[r]]++;
if(mp[v[r]]==need[v[r]]) invalid_cnt--;
r++;
}
if(term==true) break;
while(true){
if(mp[v[l]]==need[v[l]]) break;
mp[v[l]]--;
l++;
}
ans = min(ans, r-l);
mp[v[l]]--, invalid_cnt++, l++;
}
if(ans == n+1) cout << "impossible\n";
else cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
312 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1040 KB |
Output is correct |
2 |
Correct |
27 ms |
984 KB |
Output is correct |
3 |
Correct |
34 ms |
1048 KB |
Output is correct |
4 |
Correct |
31 ms |
976 KB |
Output is correct |
5 |
Correct |
157 ms |
4864 KB |
Output is correct |
6 |
Correct |
35 ms |
1068 KB |
Output is correct |
7 |
Correct |
44 ms |
1044 KB |
Output is correct |
8 |
Correct |
195 ms |
10504 KB |
Output is correct |
9 |
Correct |
111 ms |
1464 KB |
Output is correct |
10 |
Correct |
36 ms |
984 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
4 ms |
468 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
182 ms |
5132 KB |
Output is correct |
2 |
Correct |
163 ms |
4112 KB |
Output is correct |
3 |
Correct |
145 ms |
4024 KB |
Output is correct |
4 |
Correct |
27 ms |
1068 KB |
Output is correct |
5 |
Correct |
168 ms |
6068 KB |
Output is correct |
6 |
Correct |
310 ms |
10240 KB |
Output is correct |
7 |
Correct |
97 ms |
1472 KB |
Output is correct |
8 |
Correct |
134 ms |
2032 KB |
Output is correct |
9 |
Correct |
30 ms |
1012 KB |
Output is correct |
10 |
Correct |
28 ms |
980 KB |
Output is correct |
11 |
Correct |
34 ms |
1064 KB |
Output is correct |
12 |
Correct |
35 ms |
964 KB |
Output is correct |
13 |
Correct |
148 ms |
4864 KB |
Output is correct |
14 |
Correct |
32 ms |
980 KB |
Output is correct |
15 |
Correct |
47 ms |
1072 KB |
Output is correct |
16 |
Correct |
204 ms |
10456 KB |
Output is correct |
17 |
Correct |
106 ms |
1484 KB |
Output is correct |
18 |
Correct |
33 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
468 KB |
Output is correct |
23 |
Correct |
3 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |