/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 328.0 KiB
#3 Wrong Answer 20ms 540.0 KiB

Code

/*
* Created: 2025-06-13 21:20
* © 2025 NAZMUL ISLAM. All Rights Reserved.
* Author:
   __    __   ______    ________  __      __  __    __  __     
  /  |  /  | /      |  /       / /  |    /  |/  |  /  |/  |      
  $$ |  $$ |/$$$$$$  |$$$$$$$$/ $$  |   /$$ |$$ |  $$ |$$ |      
  $$$   $$ |$$ |__$$ |    /$$/  $$$    /$$$ |$$ |  $$ |$$ |      
  $$$$  $$ |$$    $$ |   /$$/   $$$$  /$$$$ |$$ |  $$ |$$ |      
  $$ $$ $$ |$$$$$$$$ |  /$$/    $$ $$ $$/$$ |$$ |  $$ |$$ |      
  $$ |$$$$ |$$ |  $$ | /$$/____ $$  $$$/ $$ |$$ |  $$ |$$ |_____ 
  $$ | $$$ |$$ |  $$ |/$$/     |$$   $/  $$ |$$    $$/ $$       |
  $$/   $$/ $$/   $$ /$$$$$$$$/ $$/      $$/  $$$$$$/  $$$$$$$$/ 
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<int, int> map_ii;
typedef map<char, int> map_ci;
typedef unsigned long long ull;
typedef map<string, int> map_si; 
typedef unordered_map<char, int> umap_ci;  
typedef unordered_map<string, int> umap_si;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
bool com(int a, int b) { return a > b ? true : false; }
ll power(ll base, ll exp){ll res = 1;base %= MOD;while (exp > 0){if (exp % 2 == 1)
res = (res * base) % MOD;base = (base * base) % MOD;exp /= 2;}return res;}
bool allElementsSame(const vector<int>& vec,int num) {if (vec.empty()) return true;
return all_of(vec.begin(), vec.end(), [&](int x) {return x == num;});}
bool isPrime(int n) {if (n <= 1) return false;if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;for (int i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0)return false;}return true;}
bool is_peak(const vll &X, const vll &Y, int N) {
    if (N <= 2)return true;
    for (int i = 1; i < N - 1; ++i) {
        bool cond1 = (X[i] > Y[i - 1] && X[i] > Y[i + 1]);
        bool cond2 = (Y[i] > X[i - 1] && Y[i] > X[i + 1]);
        if (!(cond1 || cond2)) return false;
    } return true;
}

void solve() {
    int N;cin >> N;
    vll 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 (is_peak(A, B, N)) {
        cout << "Yes\n";
        return;
    }
    if (is_peak(B, A, N)) {
        cout << "Yes\n";
        return;
    }cout << "No\n";
    return;
}
int main(){
    FAST_IO
    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:21:20
Judged At
2025-06-13 16:21:20
Judged By
Score
0
Total Time
20ms
Peak Memory
540.0 KiB