/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 21ms 540.0 KiB

Code

#include <bits/stdc++.h>

#define int long long
#define ull unsigned long long
#define pf push_front
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define endl "\n"
using namespace std;

void solve(int tt) {
    int n;
    cin >> n;

    vi a(n), b(n);
    for (auto &x : a)
        cin >> x;
    for (auto &x : b)
        cin >> x;

    sort(all(b));
    sort(all(a));

    if (n == 1) {
        cout << "Yes" << endl;
        return;
    }

    if (n == 2) {
        if (a[0] < b[n - 1] or b[0] < a[n - 1]) {
            cout << "Yes" << endl;
        } else
            cout << "No" << endl;
        return;
    }

    string ans = "No";

    if ((a[0] < b[n - 2] and a[n - 1] < b[n - 1]) or
        (b[0] < a[n - 2] and b[n - 1] < a[n - 1]))
        ans = "Yes";

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

#ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int testcase = 1;
    cin >> testcase;

    for (int tt = 1; tt <= testcase; tt++) {
        solve(tt);
    }

    return 0;
}

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 16:07:16
Judged At
2025-06-13 16:07:16
Judged By
Score
0
Total Time
21ms
Peak Memory
540.0 KiB