/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

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

#define Alhamdulillah ios_base::sync_with_stdio(0), cin.tie(0);
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define db(i) cout << "c -> " << i << endl;
#define pv(v) for(auto e : v)   cout << e << " ";   cout << endl;
#define pm(m) for(auto [x,y] : m)   cout << x << " " << y << endl;   cout << endl;

void solve(){
    int N;  cin >> N;
    int a[N+1], b[N+1];
    a[0] = 0,b[0] = 0;

    for(int i=1;i<=N;i++)   cin >> a[i];
    for(int i=1;i<=N;i++)   cin >> b[i];

    sort(a, a + N + 1);
    sort(b, b + N + 1);

    // pv(a)
    // pv(b)
    
    for(int i=2;i<=N-2;i++){
        if(!(a[i] > b[i-1] && a[i] > b[i+1]) && !(b[i] > a[i-1] && b[i] > a[i+1])){
            cout << "No\n";
            return;
        }
    }

    cout << "Yes\n";
}

int main(){
    Alhamdulillah
    int t=1;    cin >> t;
    while(t--)  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 16:00:26
Judged At
2025-06-13 16:00:26
Judged By
Score
0
Total Time
21ms
Peak Memory
800.0 KiB