/ 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 53ms 596.0 KiB
#4 Wrong Answer 54ms 324.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
   int t;
   cin>>t;
   while(t--)
   {
      long long n;
      cin>>n;
      vector<long long>a(n);
      vector<long long>b(n);

     // vector<long long>a1;
    //  vector<long long>b1;

      for(int i=0;i<n;i++)
      {
          cin>>a[i];
         // a1.push_back(a[i]);
      }

       for(int i=0;i<n;i++)
      {
          cin>>b[i];
         // b1.push_back(b[i]);
      }


      //prothome a b dekhi

      sort(a.begin(),a.end());
        sort(b.begin(),b.end());

        int check1=0;

        int j=0;

        int last_even=0;
        int last_odd=0;

      for(int i=2;i<n;i++)  //a er prothom 2 taa ekhon dekhaar dorkaar naai jehetu a check kortaachi
      {
          //int ind=i+1;

          if(i<=3)
          {



          if(b[j]<a[i]&&b[j+1]<a[i])
          {
              j+=2;
            //  continue;
          }
          else
          {
             check1++;
             break;
          }

          if(i%2==0)
          {
              last_even=b[j];
          }
          else
          {
              last_odd=b[j];
          }

          }
          else  //4 baa taar theke boro
          {

              if(i%2==0)
              {
                  long long temp1=last_even;
                  long long temp2=b[j];

                  if(a[i]>temp1&&a[i]>temp2)
                  {
                      last_even=b[j];
                      j++;
                      continue;
                  }
                  else
                  {
                      check1++;
                      break;
                  }

              }
               else if(i%2!=0)
              {
                  long long temp1=last_odd;
                  long long temp2=b[j];

                  if(a[i]>temp1&&a[i]>temp2)
                  {
                      last_odd=b[j];
                      j++;
                      continue;
                  }
                  else
                  {
                      check1++;
                      break;
                  }

              }

          }


      }




      //ebar b aar a dekhi

      last_even=0;
      last_odd=0;

      j=0;

      int check2=0;




        for(int i=2;i<n;i++)  //a er prothom 2 taa ekhon dekhaar dorkaar naai jehetu a check kortaachi
      {
         // int ind=i+1;

          if(i<=3)
          {



          if(a[j]<b[i]&&a[j+1]<b[i])
          {
              j+=2;
             // continue;
          }
          else
          {
             check2++;
             break;
          }

          if(i%2==0)
          {
              last_even=a[j];
          }
          else
          {
              last_odd=a[j];
          }

          }
          else  //4 baa taar theke boro
          {

              if(i%2==0)
              {
                  long long temp1=last_even;
                  long long temp2=a[j];

                  if(b[i]>temp1&&b[i]>temp2)
                  {
                      last_even=a[j];
                      j++;
                      continue;
                  }
                  else
                  {
                      check2++;
                      break;
                  }

              }
               else if(i%2!=0)
              {
                  long long temp1=last_odd;
                  long long temp2=a[j];

                  if(b[i]>temp1&&b[i]>temp2)
                  {
                      last_odd=a[j];
                      j++;
                      continue;
                  }
                  else
                  {
                      check2++;
                      break;
                  }

              }

          }


      }

     // cout<<check1<<" "<<check2<<endl;


      if(check1!=0&&check2!=0)
        cout<<"No"<<endl;
      else
        cout<<"Yes"<<endl;
   }
}

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:39:18
Judged At
2025-06-13 16:39:18
Judged By
Score
5
Total Time
54ms
Peak Memory
596.0 KiB