/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 24ms 532.0 KiB

Code

/*
 * Name : Md. Fahmidur Rahman Nafi
 * Date : 2025-06-13   Time : 20:50:23
 */

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

void solve(){
    int n;
    cin >> n;
    vector <ll> a(n), b(n), A, B;
    for (auto &i : a) cin >> i;
    for (auto &i : b) cin >> i;
    
    sort(b.begin(), b.end());
    sort(a.begin(), a.end());

    if (n == 1 || n == 2){
        cout << "Yes" << endl;
    }
    else{
        A = a;
        B = b;

        if (a.back() == b.back()){
            cout << "No" << endl;
        }
        else if(a.back() > b.back()){ // A boro 
            for (int i = 0; i < n; i++){
                if (a[i] < b[i]){
                    cout << "No" << endl;
                    return;
                }
            }
            cout << "Yes" << endl;
        }
        else{
            for (int i = 0; i < n; i++){
                if (a[i] > b[i]){
                    cout << "No" << endl;
                    return;
                }
            }
            cout << "Yes" << endl;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1193 C. Roy and Peak Array
Contest
Brain Booster #10
Language
C++17 (G++ 13.2.0)
Submit At
2025-06-13 17:27:38
Judged At
2025-06-13 17:27:38
Judged By
Score
0
Total Time
24ms
Peak Memory
532.0 KiB