/ SeriousOJ /

Record Detail

Compile Error

foo.cc:6:10: fatal error: trace.cpp: No such file or directory
    6 | #include "trace.cpp"
      |          ^~~~~~~~~~~
compilation terminated.

Code

#include <bits/stdc++.h>

using namespace std;

#ifndef ONLINE_JUDGE
#include "trace.cpp"
#else
#define dbg(...)
#endif

bool check(vector<int> a, vector<int> b) {
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  int n = a.size();
  if (n < 3) return true;
  if (n == 3) {
    return a[0] > max(b[1], b[2]) || b[0] > max(a[1], b[2]);
  }
  int last = b.back(); b.pop_back();
  int cnt = (n - 1) / 2;
  for (int i = n - 3; i >= 0; --i, --cnt) {
    if (cnt == 0) {
      last = b.back(); b.pop_back();
      cnt = (n - 1) / 2;
    }
    if (last >= a[i]) return false;
    last = b.back();
    b.pop_back();
  }
  assert(cnt == 0 || cnt == 1);
  assert(b.empty());
  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 17:42:31
Judged At
2025-06-13 17:42:31
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes