/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

// IN THE NAME OF ALLAH
// Coded by Ahsanul Imam
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>order_set;
// find_by_order() - Returns an iterator to the k-th largest element(counting from zero)
// order_of_key() - The number of items in a set that are strictly smaller than our item
typedef long long int ll;
const int  MOD = 1000000007;
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define f first
#define s second
#define nl '\n';
#define bit(a) __builtin_popcountll(a)
#define cnt_sese_sunno(x) __builtin_ctz(x)
#define cnt_age_sunno(x) __builtin_clz(x)
#define cnt_sese_ek(x) __builtin_ctz(~x)
#define cnt_age_ek(x) __builtin_clz(~x)
#define parity(x) __builtin_parity(x)
#define parityLL(x) __builtin_parityll(x)
#define w(x) while (x--)
#define test int t; cin>>t; for (int i = 1; i <= t; i++)
#define loop for (int i = 0; i < n; i++)
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define srt(v) sort(v.begin(), v.end());
#define rsrt(v) sort(v.rbegin(), v.rend());
#define gcd(a, b) __gcd<long long int>(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define pi 2*acos(0.0)
#define pr pair<int, int>
#define Ahsanul (ios_base::sync_with_stdio(false), cin.tie(NULL))
vector<pr>knight_posible{{2, 1}, {2, -1}, {1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {-2, 1}, {-2, -1}};//knight moves
vector<pr>posible{{0,-1},{0,1},{-1,0},{1,0},{-1,-1},{-1,1},{1,-1},{1,1}};//eight direction moves;
int power(int a,int b){int res=1;while (b){if (b&1){res=(res*1ll*a)%MOD;}a=(a*1ll*a)%MOD;b>>=1;}return res;}
ll inversemod(ll base) { return power(base,MOD-2); }
void solve()
{
    int n; cin>>n;
    deque<int>v(n),ans;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int cnt=1;
    ans.pb(min(v.front(),v.back()));
    if(v.front()<v.back())
    {
        v.pop_front();
    }
    else
    {
        v.pop_back();
    }
    int i=1,j=n-1;
    while(cnt<n)
    {
        int mini=min(v.front(),v.back());
        if(mini<=ans.front())
        {
            ans.push_front(mini);
        }
        else if(mini>=ans.back())
        {
            ans.push_back(mini);
        }
        else
        {
            cout<<"NO"<<nl;
            return;
        }
        if(v.front()<v.back())
        {
            v.pop_front();
        }
        else
        {
            v.pop_back();
        }
        cnt++;
    }
    //print(ans);
    cout<<"YES"<<nl;
}
int main()
{
    Ahsanul;
    test
    {
        //cout<<"Case "<<i<<": ";
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1229 Array of Beauty
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-05 10:21:34
Judged At
2025-09-05 10:21:34
Judged By
Score
50
Total Time
4ms
Peak Memory
600.0 KiB