/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 344.0 KiB
#2 Wrong Answer 2ms 540.0 KiB
#3 Wrong Answer 23ms 796.0 KiB

Code

/*
 *Copyright (c) Swadheen Islam Robi (SIR01)
 *Created on Fri Jun 13 2025 8:30:16 PM
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pie 2*(acos(0.0))
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define pb push_back
#define endl "\n"
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define ALLAHU_AKBAR ios::sync_with_stdio(false); cin.tie(nullptr);

// void sir1()
// {
//     ll n; cin>>n;
//     ll x = sqrt(n);
//     ll ans = 0;
//     for(ll i =1; i<=x; i++)
//     {
//         ll j = i+1;
//         if(i*i<=n) ans++;
//         if(i*j<=n) ans++;
//     }
//     cout<<ans<<endl;
    
// }
// void sir2()
// {
//     ll a,b,c; cin>>a>>b>>c;
//     ll cnt = 0;
//     ll ans;
//     if(a%2)cnt++;
//     if(b%2)cnt++;
//     if(c%2)cnt++;
//     if(cnt<2) ans = a+b+c;
//     else if(cnt==2) ans = (a+b+c)-1;
//     else ans = (a+b+c)-2;
//     cout<<ans<<endl;

// }
void sir3()
{
    ll n; cin>>n;
    vector<ll>a(n),b(n);
    for(auto &e:a) cin>>e;
    for(auto &d:b) cin>>d;
    if(n<=2)
    {
        yes; return;
    }
    rsrt(a); srt(b);
    bool ok = true;
    for(ll 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]))) {
            ok = false;
            break;
        }
    }

    if(ok)
    {
        yes; return;
    }
    srt(a); rsrt(b);
    ok = true;
    for(ll 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]))) {
            ok = false;
            break;
        }
    }
    if(ok)
    {
        yes; return;
    }
    no;
    return;
}

int main() {
    ALLAHU_AKBAR

    ll t = 1;
    cin>>t;
    while(t--)
    {
        sir3();
    }
    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:16:26
Judged At
2025-06-13 16:16:26
Judged By
Score
0
Total Time
23ms
Peak Memory
796.0 KiB