Submission #58950653


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+10;
int a[N],b[N];
int n,m,ans;
bool flag=0;
int now;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    sort(a+1,a+n+1);
    sort(b+1,b+n);
    now=n-1;
    for(int i=n;i>=1;i--){
        if(b[now]<a[i]){
            if(flag){
                cout<<"-1"<<endl;
                return 0;
            }
            else {
                ans=a[i];
                flag=1;
            }
        }
        else{
            now--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Prepare Another Box
User tzy090420
Language C++ 20 (gcc 12.2)
Score 350
Code Size 683 Byte
Status AC
Exec Time 122 ms
Memory 6784 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3488 KiB
00_sample_01.txt AC 1 ms 3652 KiB
00_sample_02.txt AC 1 ms 3500 KiB
01_random_00.txt AC 42 ms 4648 KiB
01_random_01.txt AC 47 ms 4672 KiB
01_random_02.txt AC 120 ms 6696 KiB
01_random_03.txt AC 120 ms 6776 KiB
02_random2_00.txt AC 120 ms 6684 KiB
02_random2_01.txt AC 120 ms 6576 KiB
02_random2_02.txt AC 121 ms 6572 KiB
02_random2_03.txt AC 120 ms 6564 KiB
02_random2_04.txt AC 121 ms 6784 KiB
02_random2_05.txt AC 118 ms 6772 KiB
02_random2_06.txt AC 120 ms 6772 KiB
02_random2_07.txt AC 120 ms 6584 KiB
02_random2_08.txt AC 120 ms 6768 KiB
02_random2_09.txt AC 120 ms 6684 KiB
02_random2_10.txt AC 121 ms 6568 KiB
02_random2_11.txt AC 120 ms 6592 KiB
02_random2_12.txt AC 120 ms 6576 KiB
02_random2_13.txt AC 120 ms 6552 KiB
02_random2_14.txt AC 122 ms 6576 KiB
02_random2_15.txt AC 120 ms 6568 KiB
03_random3_00.txt AC 121 ms 6580 KiB
03_random3_01.txt AC 122 ms 6560 KiB
03_random3_02.txt AC 121 ms 6620 KiB
04_handmade_00.txt AC 1 ms 3444 KiB
04_handmade_01.txt AC 1 ms 3496 KiB
04_handmade_02.txt AC 1 ms 3448 KiB
04_handmade_03.txt AC 109 ms 6612 KiB