/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 43ms 596.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define yes cout << "Yes\n"
#define no cout << "No\n"

bool check(vector<int> &A, vector<int> &B, int n)
{
    for (int i = 1; i < n - 1; i++)
    {
        if (A[i] > B[i - 1] && A[i] > B[i + 1])
            continue;
        else if (B[i] > A[i - 1] && B[i] > A[i + 1])
            continue;
        else
            return false;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> A(n), B(n);
        for (int i = 0; i < n; i++)
            cin >> A[i];
        for (int i = 0; i < n; i++)
            cin >> B[i];
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());

        if (n <= 2 || check(A, B, n) || check(B, A, n))
        {
            yes;
        }
        else
        {
            no;
        }
    }
    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:47:06
Judged At
2025-06-13 17:47:06
Judged By
Score
0
Total Time
43ms
Peak Memory
596.0 KiB