53612023-04-26 14:02:09horvathabelNövekvő Ödön és a Másoló Varázslócpp17Wrong answer 5/100250ms96048 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);
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Wrong answer63ms4596 KiB
subtask20/5
3Accepted101ms8596 KiB
4Accepted131ms10628 KiB
5Wrong answer160ms12772 KiB
subtask30/10
6Wrong answer3ms9584 KiB
7Wrong answer3ms9652 KiB
8Wrong answer3ms9568 KiB
subtask40/15
9Wrong answer3ms9980 KiB
10Wrong answer3ms9848 KiB
11Wrong answer3ms10184 KiB
12Wrong answer3ms10300 KiB
subtask55/5
13Accepted8ms10720 KiB
14Accepted8ms10948 KiB
15Accepted8ms11172 KiB
subtask60/5
16Wrong answer8ms11368 KiB
17Wrong answer8ms11672 KiB
18Wrong answer8ms12004 KiB
19Accepted8ms12076 KiB
subtask70/10
20Wrong answer8ms12400 KiB
21Wrong answer8ms12628 KiB
22Wrong answer8ms12700 KiB
23Wrong answer6ms12736 KiB
24Wrong answer8ms13092 KiB
subtask80/25
25Wrong answer123ms18872 KiB
26Wrong answer125ms20608 KiB
27Wrong answer123ms22560 KiB
28Accepted3ms18688 KiB
29Wrong answer123ms24480 KiB
30Wrong answer123ms26408 KiB
31Wrong answer123ms28612 KiB
32Wrong answer123ms30392 KiB
33Wrong answer123ms32224 KiB
34Wrong answer128ms34152 KiB
35Wrong answer123ms36088 KiB
36Wrong answer123ms38032 KiB
37Wrong answer123ms39984 KiB
38Wrong answer125ms41932 KiB
39Wrong answer123ms43868 KiB
40Wrong answer123ms45784 KiB
41Wrong answer123ms47724 KiB
42Wrong answer79ms47680 KiB
43Wrong answer125ms50800 KiB
44Wrong answer134ms52736 KiB
45Wrong answer123ms54672 KiB
subtask90/25
46Wrong answer250ms61880 KiB
47Wrong answer248ms65820 KiB
48Wrong answer250ms69684 KiB
49Wrong answer250ms73560 KiB
50Wrong answer250ms77368 KiB
51Wrong answer250ms81368 KiB
52Wrong answer226ms84220 KiB
53Wrong answer238ms88072 KiB
54Wrong answer248ms92224 KiB
55Wrong answer246ms96048 KiB