/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Wrong Answer 57ms 656.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define optimize()                   \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL); /*cout.tie(NULL);*/
#define fraction()               \
   cout.unsetf(ios::floatfield); \
   cout.precision(20);           \
   cout.setf(ios::fixed, ios::floatfield);
#define file()                       \
   freopen("input.txt", "r", stdin); \
   freopen("output", "w", stdout);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
int lcm(int a, int b) { return (a * b) / __gcd(a, b); }
int gcd(int a, int b) { return __gcd(a, b); }
typedef pair<int, int> pr;
typedef long long ll;
#define el "\n"
const int mod = 1e9 + 7;
const int mx = 1e5 + 125;

bool com(const pair<int, int> &p1, const pair<int, int> &p2)
{
   // if (p1.first == p2.first)
   // {
   //     return p1.second > p2.second;
   // }
   return p1.first < p2.first;
}

void giveanswer()
{
   ll n, m, i;
   cin >> n;
   vector<ll> a(n), b(n);
   ordered_set<ll> os1, os2;
   if (n == 1)
   {
      for (i = 0; i < n; i++)
      {
         cin >> a[i];
         os1.insert(a[i]);
      }
      os1.insert(0);
      os1.insert(0);
      for (i = 0; i < n; i++)
      {
         cin >> b[i];
         os2.insert(b[i]);
      }
      os2.insert(0);
      os2.insert(0);
   }
   else
   {
      for (i = 0; i < n; i++)
      {
         cin >> a[i];
         os1.insert(a[i]);
      }
      for (i = 0; i < n; i++)
      {
         cin >> b[i];
         os2.insert(b[i]);
      }
   }
   sort(a.begin(), a.end(), greater<ll>());
   sort(b.begin(), b.end(), greater<ll>());
   ll x=2;
   bool f=0;
   int sz=max(1*1LL,n/2);
   for (i = 0; i < sz; i++)
   {
      int t=os2.order_of_key(a[i]);
      if(t>=x)
      {
         x+=2;
      }
      else{ f=1;break;}
   }
   if(f==0)
   {
      cout<<"Yes"<<el;
      return;
   }
   x=2;
   for (i = 0; i < sz; i++)
   {
      int t=os1.order_of_key(b[i]);
      //cout<<t<<el;
      if(t>=x)
      {
         x+=2;
      }
      else
      {
         cout<<"No"<<el;
         return;
      }
   }
   cout<<"Yes"<<el;

}

int main()
{
   optimize();
   fraction();
   int t;
   cin >> t;
   while (t--)
   {
   giveanswer();
   }
}

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:38:09
Judged At
2025-06-13 17:38:09
Judged By
Score
0
Total Time
57ms
Peak Memory
656.0 KiB