/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Wrong Answer 45ms 576.0 KiB
#4 Wrong Answer 37ms 596.0 KiB

Code

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

#define ll long long
#define int long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n), b(n);
        multiset<int> s1, s2;
        f(i, n)
        {
            cin >> a[i];
            s1.insert(a[i]);
        }
        f(i, n)
        {
            cin >> b[i];
            s2.insert(b[i]);
        }
        if (n < 3)
        {
            cout << "Yes\n";
            continue;
        }
        // try a;
        sort(all(a));
        sort(all(b));
        reverse(all(b));
        vector<int> ta(n);
        int j = 1, i = n - 1;
        while (j < n - 1)
        {
            ta[j++] = a[i--];
        }
        int f = 1;
        for (int i = 1; i < n - 1; i++)
        {
            if (ta[i] > b[i - 1] and ta[i] > b[i + 1])
            {
            }
            else
                f = 0;
        }
        if (f)
        {
            cout << "Yes\n";
            continue;
        }
        // try b;
        sort(all(b));
        sort(all(a));
        vector<int> tb(n);
        reverse(all(a));
        j = 1, i = n - 1;
        while (j < n - 1)
        {
            tb[j++] = b[i--];
        }
        f = 1;
        for (int i = 1; i < n - 1; i++)
        {
            if (tb[i] > a[i - 1] and tb[i] > a[i + 1])
            {
            }
            else
                f = 0;
        }
        if (f)
        {
            cout << "Yes\n";
            continue;
        }
        cout << "No\n";
    }
}

Information

Submit By
Type
Submission
Problem
P1193 C. Roy and Peak Array
Contest
Brain Booster #10
Language
C++11 (G++ 13.2.0)
Submit At
2025-06-13 16:51:38
Judged At
2025-06-13 16:51:38
Judged By
Score
5
Total Time
45ms
Peak Memory
596.0 KiB