/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 3ms 836.0 KiB
#3 Accepted 5ms 532.0 KiB
#4 Accepted 9ms 580.0 KiB
#5 Accepted 8ms 616.0 KiB
#6 Wrong Answer 7ms 788.0 KiB
#7 Wrong Answer 4ms 536.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll n; cin >> n;
        
        deque<ll> dq;
        for (ll i = 1; i <= n; i++) {
            ll a; cin >> a;
            dq.push_back(a);
        }

        deque<ll> temp;
        for (ll i = 1; i <= n; i++) {
            ll mn = min(dq.front(), dq.back());

            if (temp.empty()) temp.push_back(mn);
            else {
                if (temp.front() >= mn) temp.push_front(mn);
                else temp.push_back(mn);
            }

            if (dq.front() == mn) dq.pop_front();
            else dq.pop_back();
        }

        vector<ll> v;
        for (auto &u : temp) v.push_back(u);
        
        if (is_sorted(v.begin(), v.end()) and v[0] <= v.back()) cout << "YES\n";
        else cout << "NO\n";
    }
}

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:15:14
Judged At
2025-09-02 16:15:14
Judged By
Score
50
Total Time
9ms
Peak Memory
836.0 KiB