5361 | 2023-04-26 14:02:09 | horvathabel | Növekvő Ödön és a Másoló Varázsló | cpp17 | Wrong answer 5/100 | 250ms | 96048 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<int> v, v2;
priority_queue<int, vector<int>, greater<int>> q;
priority_queue<int> pq;
for (int i=0;i<n;i++){
int a;
cin>>a;
v.push_back(a);
v2.push_back(a);
}
for (int i=0;i<m;i++){
int a;
cin>>a;
q.push(a);
pq.push(a);
}
int curr=v[0];
int ans=0;
for (int i=1; i<n;i++){
if (curr>=v[i]){
while (q.top()<=curr && !q.empty()){
q.pop();
}
if (q.empty()){
ans=1e9;
break;
}
v[i]=q.top();
ans++;
}
curr=v[i];
}
int ans2=0;
curr=v2[n-1];
for (int i=n-2;i>=0;i--){
if (curr<=v2[i]){
while (pq.top()>=curr && !pq.empty()){
pq.pop();
}
if (pq.empty()){
ans2=1e9;
break;
}
v2[i]=pq.top();
ans2++;
}
curr=v2[i];
}
cout<<min(ans, ans2);
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1812 KiB | ||||
2 | Wrong answer | 63ms | 4596 KiB | ||||
subtask2 | 0/5 | ||||||
3 | Accepted | 101ms | 8596 KiB | ||||
4 | Accepted | 131ms | 10628 KiB | ||||
5 | Wrong answer | 160ms | 12772 KiB | ||||
subtask3 | 0/10 | ||||||
6 | Wrong answer | 3ms | 9584 KiB | ||||
7 | Wrong answer | 3ms | 9652 KiB | ||||
8 | Wrong answer | 3ms | 9568 KiB | ||||
subtask4 | 0/15 | ||||||
9 | Wrong answer | 3ms | 9980 KiB | ||||
10 | Wrong answer | 3ms | 9848 KiB | ||||
11 | Wrong answer | 3ms | 10184 KiB | ||||
12 | Wrong answer | 3ms | 10300 KiB | ||||
subtask5 | 5/5 | ||||||
13 | Accepted | 8ms | 10720 KiB | ||||
14 | Accepted | 8ms | 10948 KiB | ||||
15 | Accepted | 8ms | 11172 KiB | ||||
subtask6 | 0/5 | ||||||
16 | Wrong answer | 8ms | 11368 KiB | ||||
17 | Wrong answer | 8ms | 11672 KiB | ||||
18 | Wrong answer | 8ms | 12004 KiB | ||||
19 | Accepted | 8ms | 12076 KiB | ||||
subtask7 | 0/10 | ||||||
20 | Wrong answer | 8ms | 12400 KiB | ||||
21 | Wrong answer | 8ms | 12628 KiB | ||||
22 | Wrong answer | 8ms | 12700 KiB | ||||
23 | Wrong answer | 6ms | 12736 KiB | ||||
24 | Wrong answer | 8ms | 13092 KiB | ||||
subtask8 | 0/25 | ||||||
25 | Wrong answer | 123ms | 18872 KiB | ||||
26 | Wrong answer | 125ms | 20608 KiB | ||||
27 | Wrong answer | 123ms | 22560 KiB | ||||
28 | Accepted | 3ms | 18688 KiB | ||||
29 | Wrong answer | 123ms | 24480 KiB | ||||
30 | Wrong answer | 123ms | 26408 KiB | ||||
31 | Wrong answer | 123ms | 28612 KiB | ||||
32 | Wrong answer | 123ms | 30392 KiB | ||||
33 | Wrong answer | 123ms | 32224 KiB | ||||
34 | Wrong answer | 128ms | 34152 KiB | ||||
35 | Wrong answer | 123ms | 36088 KiB | ||||
36 | Wrong answer | 123ms | 38032 KiB | ||||
37 | Wrong answer | 123ms | 39984 KiB | ||||
38 | Wrong answer | 125ms | 41932 KiB | ||||
39 | Wrong answer | 123ms | 43868 KiB | ||||
40 | Wrong answer | 123ms | 45784 KiB | ||||
41 | Wrong answer | 123ms | 47724 KiB | ||||
42 | Wrong answer | 79ms | 47680 KiB | ||||
43 | Wrong answer | 125ms | 50800 KiB | ||||
44 | Wrong answer | 134ms | 52736 KiB | ||||
45 | Wrong answer | 123ms | 54672 KiB | ||||
subtask9 | 0/25 | ||||||
46 | Wrong answer | 250ms | 61880 KiB | ||||
47 | Wrong answer | 248ms | 65820 KiB | ||||
48 | Wrong answer | 250ms | 69684 KiB | ||||
49 | Wrong answer | 250ms | 73560 KiB | ||||
50 | Wrong answer | 250ms | 77368 KiB | ||||
51 | Wrong answer | 250ms | 81368 KiB | ||||
52 | Wrong answer | 226ms | 84220 KiB | ||||
53 | Wrong answer | 238ms | 88072 KiB | ||||
54 | Wrong answer | 248ms | 92224 KiB | ||||
55 | Wrong answer | 246ms | 96048 KiB |