/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 28ms 844.0 KiB

Code

#include <bits/stdc++.h>

using namespace std;

bool check(vector<int> a, vector<int> b) {
  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());
  int n = a.size();
  vector<int> nb(n);
  int l = 0, r = 1;
  while (l < n && r < n) {
    nb[l] = b.back(); b.pop_back();
    l += 2;
    if (l < n) nb[l] = b.back(), b.pop_back(), l += 2;
    nb[r] = b.back(); b.pop_back();
    r += 2;
    if (r < n) nb[r] = b.back(), b.pop_back(), r += 2;
  }
  a.erase(a.begin());
  for (int i = 1; i < a.size(); i++) {
    if (a[i] <= nb[i + 1]) {
      return false;
    }
  }
  return true;
}

void solve(int cs) {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;

  cout << ((check(a, b) || check(b, a)) ? "Yes\n" : "No\n");
}

int32_t main() {
  cin.tie(0) -> sync_with_stdio(0);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  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:07:24
Judged At
2025-06-13 16:07:24
Judged By
Score
0
Total Time
28ms
Peak Memory
844.0 KiB