/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Runtime Error 1ms 532.0 KiB
#2 Runtime Error 3ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

void solve(){
     int n;
     cin >> n;
     vector <ll> a(n);
     for (auto &i : a) cin >> i;
     deque <ll> dq;

     int i = 0, j = n - 1;
     bool pos = true;

     while (i <= j && pos){
        int c;
        if (a[i] <= a[j]){
            c = a[i];
            i++;
        }
        else{
            c = a[j];
            j--;
        }

        if (dq.front() >= c){
            dq.push_front(c);
        }
        else if (dq.back() <= c){
            dq.push_back(c);
        }
        else{
            pos = false;
            break;
        }
     }

     cout << (pos ? "YES" : "NO") << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1229 Array of Beauty
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 06:05:09
Judged At
2025-09-01 06:05:09
Judged By
Score
0
Total Time
3ms
Peak Memory
532.0 KiB