/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 524.0 KiB
#3 Wrong Answer 21ms 532.0 KiB
#4 Wrong Answer 20ms 576.0 KiB

Code

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;

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

    auto check = [&](vector<int> vec1, vector<int> vec2) -> bool {
        for(int i = 2, j = 0; i < n; i++, j++) {
            if(vec1[i] > vec2[j] && vec1[i] > vec2[j + 2]) continue;
            return 0;
        }
        return 1;
    };
    if(check(a, b) or check(b, a)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1193 C. Roy and Peak Array
Language
C++17 (G++ 13.2.0)
Submit At
2025-06-01 18:04:52
Judged At
2025-06-01 18:04:52
Judged By
Score
5
Total Time
21ms
Peak Memory
576.0 KiB