/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 536.0 KiB
#2 Wrong Answer 2ms 540.0 KiB
#3 Wrong Answer 43ms 584.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define ll long long
#define ull unsigned long long
#define ld long double
const int MAX_n = 1e5 + 5;
#define MAX_X 1000000
const int InF = 1e9; // for int
const ll INF = 1e18; // for ll

bool fuska(const vector<int> &a, const vector<int> &b, int n)
{
    for (int 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]))
        {
            return false;
        }
    }

    return true;
}

void solve()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        vector<int> 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(), greater<>());
        bool ans = 0;
        if (fuska(a, b, n))
        {
            ans = 1;
        }
        sort(a.begin(), a.end(), greater<>());
        sort(b.begin(), b.end());
        if (fuska(a, b, n))
        {
            ans = 1;
        }

        if (ans)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    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:34:56
Judged At
2025-06-13 16:34:56
Judged By
Score
0
Total Time
43ms
Peak Memory
584.0 KiB