/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include <bits/stdc++.h>
#define nl '\n'
#define ll long long int
#define all(c) c.begin(),c.end()
#define print(c) for(auto e : c) cout << e << " "; cout << nl
using namespace std;
void solve()
{
    int n; cin >> n;
    vector<int> a(n), b(n);
    for(auto &e: a) cin >> e;
    for(auto &e: b) cin >> e;
    
    sort(all(a)); reverse(all(a));
    sort(all(b)); 
    
    bool ok = true;
    for(int i=1; i<n-1; i++)
    {
        if(a[i] <= b[i-1] || a[i] <= b[i+1])
        {
            ok = false;
        }
    }
    
    if(ok)
    {
        cout << "Yes" << nl; return;
    }
    
    reverse(all(a));
    reverse(all(b));
    
    ok = true;
    for(int i=1; i<n-1; i++)
    {
        if(b[i] <= a[i-1] || b[i] <= a[i+1])
        {
            ok = false;
        }
    }
    
    if(ok) cout << "Yes" << nl;
    else cout << "No" << nl;
} 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t = 1; 
    cin >> t; // multiple tc
    for(int tt = 1; tt <= t; tt++)
    {
        // cout << "TEST CASE-" << tt << nl;
        solve();
    }

    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:30:24
Judged At
2025-06-13 17:30:24
Judged By
Score
0
Total Time
21ms
Peak Memory
576.0 KiB