#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,r,z,o=LLONG_MAX;
map<int,int>m;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>k>>r;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<r;i++){
int smth,idk;
cin>>smth>>idk;
m[smth]=idk;
}
int x=0,j=r,z=o;
for(int l=0;l<n;l++){
while(j>0&&x<n){
m[a[x]]--;
if(m[a[x]]==0){
j--;
}
x++;
}
if(j==0){
o=min(o,x-l);
}
m[a[l]]++;
if(m[a[l]]==1){
j++;
}
}
if(o==z){
cout<<"impossible";
return 0;
}
cout<<o;
return 0;}
# |
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 |
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 |
420 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 |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
2 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 |
344 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 |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1884 KB |
Output is correct |
2 |
Correct |
10 ms |
1884 KB |
Output is correct |
3 |
Correct |
16 ms |
2016 KB |
Output is correct |
4 |
Correct |
12 ms |
2136 KB |
Output is correct |
5 |
Correct |
108 ms |
6996 KB |
Output is correct |
6 |
Correct |
17 ms |
1884 KB |
Output is correct |
7 |
Correct |
33 ms |
2020 KB |
Output is correct |
8 |
Correct |
152 ms |
14304 KB |
Output is correct |
9 |
Correct |
73 ms |
2396 KB |
Output is correct |
10 |
Correct |
17 ms |
1880 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
604 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Correct |
2 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 |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
548 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 |
600 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
6992 KB |
Output is correct |
2 |
Correct |
112 ms |
5720 KB |
Output is correct |
3 |
Correct |
101 ms |
5756 KB |
Output is correct |
4 |
Correct |
9 ms |
1880 KB |
Output is correct |
5 |
Correct |
153 ms |
8272 KB |
Output is correct |
6 |
Correct |
215 ms |
13264 KB |
Output is correct |
7 |
Correct |
75 ms |
2488 KB |
Output is correct |
8 |
Correct |
95 ms |
3156 KB |
Output is correct |
9 |
Correct |
15 ms |
1880 KB |
Output is correct |
10 |
Correct |
10 ms |
1884 KB |
Output is correct |
11 |
Correct |
13 ms |
1880 KB |
Output is correct |
12 |
Correct |
13 ms |
2020 KB |
Output is correct |
13 |
Correct |
109 ms |
7004 KB |
Output is correct |
14 |
Correct |
17 ms |
1880 KB |
Output is correct |
15 |
Correct |
30 ms |
1884 KB |
Output is correct |
16 |
Correct |
153 ms |
14420 KB |
Output is correct |
17 |
Correct |
74 ms |
2396 KB |
Output is correct |
18 |
Correct |
17 ms |
1884 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
2 ms |
348 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 |
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 |
460 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |