/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 4ms 948.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 4ms 532.0 KiB
#5 Accepted 7ms 788.0 KiB
#6 Wrong Answer 7ms 788.0 KiB
#7 Wrong Answer 3ms 532.0 KiB

Code

// Allah is the best planner.He knows everything
#include<bits/stdc++.h>
using namespace std;
 
//ordered set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type,
less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
 
#define pb  push_back
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define en "\n"
typedef long long int ll;
typedef unsigned long long int ull;
  
 
  
int main()
{
fast();
 
 int t=1; 
 cin>>t;
while(t--)
{
 ll n;
cin>>n;
vector<ll>arr(n);

for(int i=0;i<n;i++)
{
cin>>arr[i];
}
ll l=0,r=n-1;
deque<ll>dq;
//dq.push_front(0);
while(l<r)
{
     ll mn=min(arr[l],arr[r]);
     if(arr[l]<arr[r])
     {
        l++;
     }
     else
     {
        r--;
     }
     if(dq.size()==0)
     {
        dq.push_back(mn);
     }
     else if(mn>dq.front())
     {
        dq.push_back(mn);
     }
     else
     {
        dq.push_front(mn);
     }
}
 ll mn=min(arr[l],arr[r]);
     if(arr[l]<arr[r])
     {
        l++;
     }
     else
     {
        r++;
     }
     if(mn>dq.front())
     {
        dq.push_back(mn);
     }
     else
     {
        dq.push_front(mn);
     }

vector<ll>temp1;
sort(arr.begin(),arr.end());

for(auto it: dq)
{
   temp1.pb(it);
}
  if(arr==temp1)
  {
    cout<<"YES"<<en;
  }
  else
  {
    cout<<"NO"<<en;
  }
}
   return 0;
}
//Not a good Coder->Rifat

Information

Submit By
Type
Submission
Problem
P1229 Array of Beauty
Contest
LUCC Presents Intra LU Junior Programming Contest - Replay
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-02 16:58:15
Judged At
2025-09-02 16:58:40
Judged By
Score
50
Total Time
7ms
Peak Memory
948.0 KiB