/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 328.0 KiB
#3 Wrong Answer 22ms 640.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

bool ck(const vector<int> &a, const vector<int> &b) {
    int n = a.size();
    for (int i = 1; i < n - 1; i++) {
        if (!((a[i] > b[i - 1] && a[i] > b[i + 1]) || (b[i] > a[i - 1] && b[i] > a[i + 1])))
            return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n), b(n);
        for (int &x : a) cin >> x;
        for (int &x : b) cin >> x;
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        vector<int> br = b, ar = a;
        reverse(br.begin(), br.end());
        reverse(ar.begin(), ar.end());
        if (ck(a, br) || ck(ar, b)) cout << "Yes\n";
        else cout << "No\n";
    }
}

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:50:03
Judged At
2025-06-13 17:50:03
Judged By
Score
0
Total Time
22ms
Peak Memory
640.0 KiB