# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932491 |
2024-02-23T13:52:52 Z |
imarn |
Martian DNA (BOI18_dna) |
C++14 |
|
273 ms |
17020 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;
ll l=1,r=n+1;
for(int i=0;i<R;i++){
ll b,q;cin>>b>>q;up[b]=q;
}
while(l<r){
int m=(l+r)>>1;
for(auto it : mp)mp[it.f]=0;
for(int i=0;i<m;i++)mp[a[i]]++;
int cnt=0;bool ch=0;
for(auto it : mp)if(up.find(it.f)!=up.end()&&it.s>=up[it.f])cnt++;
if(cnt==R)ch=1;
for(int i=m;i<n;i++){
if(up.find(a[i-m])!=up.end()&&mp[a[i-m]]==up[a[i-m]])cnt--;
mp[a[i-m]]--;
if(up.find(a[i])!=up.end()&&mp[a[i]]==up[a[i]]-1)cnt++;
mp[a[i]]++;
if(cnt==R)ch=1;
}if(ch)r=m;
else l=m+1;
}
if(l==n+1)cout<<"impossible";
else cout<<l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
2 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 |
3 ms |
604 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
504 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
600 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 |
0 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 |
82 ms |
2396 KB |
Output is correct |
2 |
Correct |
111 ms |
2392 KB |
Output is correct |
3 |
Correct |
129 ms |
2436 KB |
Output is correct |
4 |
Correct |
94 ms |
2396 KB |
Output is correct |
5 |
Correct |
188 ms |
5736 KB |
Output is correct |
6 |
Correct |
32 ms |
2416 KB |
Output is correct |
7 |
Correct |
32 ms |
2396 KB |
Output is correct |
8 |
Correct |
261 ms |
11984 KB |
Output is correct |
9 |
Correct |
131 ms |
3104 KB |
Output is correct |
10 |
Correct |
101 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
3 ms |
600 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
488 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
600 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
203 ms |
9756 KB |
Output is correct |
2 |
Correct |
209 ms |
8712 KB |
Output is correct |
3 |
Correct |
221 ms |
6508 KB |
Output is correct |
4 |
Correct |
130 ms |
2396 KB |
Output is correct |
5 |
Correct |
147 ms |
11760 KB |
Output is correct |
6 |
Correct |
273 ms |
17020 KB |
Output is correct |
7 |
Correct |
77 ms |
3676 KB |
Output is correct |
8 |
Correct |
161 ms |
4444 KB |
Output is correct |
9 |
Correct |
85 ms |
2396 KB |
Output is correct |
10 |
Correct |
109 ms |
2396 KB |
Output is correct |
11 |
Correct |
130 ms |
2392 KB |
Output is correct |
12 |
Correct |
92 ms |
2412 KB |
Output is correct |
13 |
Correct |
182 ms |
6252 KB |
Output is correct |
14 |
Correct |
31 ms |
2392 KB |
Output is correct |
15 |
Correct |
33 ms |
2588 KB |
Output is correct |
16 |
Correct |
273 ms |
12512 KB |
Output is correct |
17 |
Correct |
132 ms |
3284 KB |
Output is correct |
18 |
Correct |
94 ms |
2392 KB |
Output is correct |
19 |
Correct |
2 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
3 ms |
604 KB |
Output is correct |
22 |
Correct |
3 ms |
476 KB |
Output is correct |
23 |
Correct |
3 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
604 KB |
Output is correct |
28 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |