/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 764.0 KiB
#3 Wrong Answer 27ms 532.0 KiB
#4 Wrong Answer 46ms 572.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)
{
    b.pop_back();
    b.pop_back();
    bool f = true;
    for (int i = 0; i < b.size(); i++)
    {
        if (b[i] > a[i] && b[i] > a[i + 2])
        {
            continue;
        }
        else
        {
            f = false;
            break;
        }
    }
    return f;
}

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(), greater<int>());
        sort(B.begin(), B.end(), greater<int>());

        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:39:19
Judged At
2025-06-13 17:39:19
Judged By
Score
5
Total Time
46ms
Peak Memory
764.0 KiB