Submission #58957974


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int A[200001];
int B[200001];

int main(){
    int N;
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    for (int i=0; i<N-1; i++){
        cin >> B[i];
    }
    sort(A, A+N, greater<int>());
    sort(B, B+N-1, greater<int>());
    bool offset = false;
    int ans = 0;
    for (int i=0; i<N; i++){
        if (A[i] > B[i-offset] && offset){
            cout << -1;
            return 0;
        }
        else if (A[i] > B[i-offset]){
            ans = A[i];
            offset = true;
        }
    }
    cout << ans;
}

Submission Info

Submission Time
Task C - Prepare Another Box
User WendidIask
Language C++ 17 (gcc 12.2)
Score 350
Code Size 624 Byte
Status AC
Exec Time 121 ms
Memory 5208 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 3496 KiB
00_sample_01.txt AC 1 ms 3448 KiB
00_sample_02.txt AC 1 ms 3404 KiB
01_random_00.txt AC 41 ms 4004 KiB
01_random_01.txt AC 47 ms 4048 KiB
01_random_02.txt AC 121 ms 5048 KiB
01_random_03.txt AC 120 ms 5048 KiB
02_random2_00.txt AC 120 ms 5024 KiB
02_random2_01.txt AC 121 ms 5052 KiB
02_random2_02.txt AC 120 ms 4992 KiB
02_random2_03.txt AC 121 ms 5012 KiB
02_random2_04.txt AC 121 ms 5004 KiB
02_random2_05.txt AC 121 ms 4988 KiB
02_random2_06.txt AC 120 ms 5048 KiB
02_random2_07.txt AC 120 ms 5008 KiB
02_random2_08.txt AC 120 ms 5052 KiB
02_random2_09.txt AC 121 ms 5016 KiB
02_random2_10.txt AC 120 ms 5020 KiB
02_random2_11.txt AC 121 ms 5120 KiB
02_random2_12.txt AC 120 ms 5024 KiB
02_random2_13.txt AC 120 ms 5056 KiB
02_random2_14.txt AC 120 ms 5208 KiB
02_random2_15.txt AC 121 ms 5124 KiB
03_random3_00.txt AC 120 ms 4932 KiB
03_random3_01.txt AC 120 ms 5048 KiB
03_random3_02.txt AC 120 ms 5004 KiB
04_handmade_00.txt AC 1 ms 3468 KiB
04_handmade_01.txt AC 1 ms 3456 KiB
04_handmade_02.txt AC 1 ms 3568 KiB
04_handmade_03.txt AC 107 ms 5056 KiB