/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 588.0 KiB
#2 Accepted 1ms 332.0 KiB
#3 Wrong Answer 23ms 804.0 KiB
#4 Wrong Answer 21ms 540.0 KiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define PLL pair<long long, long long>
#define int long long
#define LL long long
 
#define faster {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define all(v) v.begin(),v.end()
 
const LL mod = 998244353;
const int N = 1e5 + 10;
 
const LL INF = 1e17 + 1;
const int inf = 1e9 + 1;

void solve(int tc) {
    int n; cin >> n;
    vector<int> a(n), b(n);
    for(auto &u: a)
        cin >> u;
    for(auto &u: b)
        cin >> u;
    auto check = [&](){
        sort(all(a));
        sort(all(b));
        if(n > 2 and n < 5) swap(b[1], b[2]);
        for(int i = 2; i < n; i++){
            if(a[i] <= b[i - 2] or a[i] <= b[i]) return 0;
        }
        return 1;
    };
    bool fl = check(); swap(a, b);
    fl |= check();
    cout << (fl ? "Yes" : "No") << '\n';
}
 
signed main() {
    faster
    int t = 1;
    cin >> t;
    for (int tc = 1; tc <= t; tc++) {
        solve(tc);
    }
    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:05:17
Judged At
2025-06-13 16:05:17
Judged By
Score
5
Total Time
23ms
Peak Memory
804.0 KiB