/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Wrong Answer 21ms 628.0 KiB
#4 Wrong Answer 20ms 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;
        return;
    }
    else{
        bool up = true, down = true;
        for (int i = 2; i < n; i++){
            if (a[i] <= b[i]){
                up = false;
            }
            if (a[i] >= b[i]){
                down = false;
            }
        }

        cout << (up || down ? "Yes" : "No") << 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:10:05
Judged At
2025-06-13 17:10:05
Judged By
Score
5
Total Time
21ms
Peak Memory
628.0 KiB