# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932576 |
2024-02-23T18:09:32 Z |
imarn |
Martian DNA (BOI18_dna) |
C++14 |
|
62 ms |
16940 KB |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=2e5+5;
unordered_map<ll,int>mp,up;
ll a[N];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,k,R;cin>>n>>k>>R;
for(int i=0;i<n;i++)cin>>a[i],mp[a[i]]=0;
for(int i=0;i<R;i++){
ll b,q;cin>>b>>q;up[b]=q;
}int cnt=0;int l=0,ans=1e9;
for(int i=0;i<n;i++){mp[a[i]]++;if(up.find(a[i])!=up.end()&&mp[a[i]]==up[a[i]])cnt++;
while(up.find(a[l])==up.end()||(cnt==R&&mp[a[l]]>up[a[l]]))mp[a[l]]--,l++;
if(cnt==R)ans=min(ans,i-l+1);
}
if(ans==1e9)cout<<"impossible";
else cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
508 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
360 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 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 |
604 KB |
Output is correct |
3 |
Correct |
2 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
604 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 |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2396 KB |
Output is correct |
2 |
Correct |
18 ms |
2416 KB |
Output is correct |
3 |
Correct |
20 ms |
2392 KB |
Output is correct |
4 |
Correct |
21 ms |
2396 KB |
Output is correct |
5 |
Correct |
42 ms |
6300 KB |
Output is correct |
6 |
Correct |
13 ms |
2396 KB |
Output is correct |
7 |
Correct |
21 ms |
2396 KB |
Output is correct |
8 |
Correct |
41 ms |
12480 KB |
Output is correct |
9 |
Correct |
31 ms |
3316 KB |
Output is correct |
10 |
Correct |
17 ms |
2424 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
648 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
480 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 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 |
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 |
0 ms |
348 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 |
53 ms |
10528 KB |
Output is correct |
2 |
Correct |
46 ms |
8808 KB |
Output is correct |
3 |
Correct |
40 ms |
6528 KB |
Output is correct |
4 |
Correct |
18 ms |
2396 KB |
Output is correct |
5 |
Correct |
55 ms |
11716 KB |
Output is correct |
6 |
Correct |
62 ms |
16940 KB |
Output is correct |
7 |
Correct |
27 ms |
3420 KB |
Output is correct |
8 |
Correct |
29 ms |
4592 KB |
Output is correct |
9 |
Correct |
16 ms |
2396 KB |
Output is correct |
10 |
Correct |
18 ms |
2648 KB |
Output is correct |
11 |
Correct |
26 ms |
2396 KB |
Output is correct |
12 |
Correct |
17 ms |
2396 KB |
Output is correct |
13 |
Correct |
45 ms |
6244 KB |
Output is correct |
14 |
Correct |
13 ms |
2396 KB |
Output is correct |
15 |
Correct |
16 ms |
2392 KB |
Output is correct |
16 |
Correct |
42 ms |
12508 KB |
Output is correct |
17 |
Correct |
22 ms |
3164 KB |
Output is correct |
18 |
Correct |
17 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
580 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 |
464 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 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 |