/ SeriousOJ /

Record Detail

Wrong Answer


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

Code


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using vll = vector<ll>;

void done() {
    int n;
    cin >> n;
    vll a(n), b(n);
    for (ll &x : a) cin >> x;
    for (ll &x : b) cin >> x;

    if (n < 3) {
        cout << "Yes\n";
        return;
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    bool f = true;
    for (int i = 1; i < n - 1; ++i) {
        bool is_peak = (a[i] > b[i+1]) || (b[i] > a[i+1]);
        if (!is_peak) {
            f = false;
            break;
        }
    }

    cout << (f ? "Yes\n" : "No\n");
}

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

    int t;
    cin >> t;
    while (t--) {
        done();
    }
    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 17:32:06
Judged At
2025-06-13 17:32:06
Judged By
Score
0
Total Time
21ms
Peak Memory
532.0 KiB