/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 340.0 KiB
#2 Accepted 2ms 532.0 KiB
#3 Accepted 2ms 532.0 KiB
#4 Accepted 3ms 572.0 KiB
#5 Accepted 3ms 532.0 KiB
#6 Wrong Answer 3ms 532.0 KiB
#7 Wrong Answer 2ms 320.0 KiB

Code

#include <bits/stdc++.h>     //   All praise is due to Allah alone, and peace and blessings be
using namespace std;         //         upon him, after whom there is no other Prophet.

int32_t main() {
    cin.tie(0)->sync_with_stdio(false);

    int32_t Case = 1;    cin >> Case;
    for (int T = 1; T <= Case; T++) {

        int n; cin >> n;
        int ar[n]; for(int & i : ar) cin >> i;

        function<void()> Test_Case = [&]() {
            deque<int> br;
            int i = 0, j = n - 1;
            while(i <= j) {
                if(ar[i] <= ar[j]) {
                    if(br.empty()) {
                        br.emplace_back(ar[i++]);
                        continue;
                    }
                    else {
                        if(ar[i] <= br.front() and ar[j] >= br.back()) {
                            int dist = br.front() - ar[i], tsid = ar[j] - br.back();
                            if(dist <= tsid) {
                                br.push_front(ar[i++]);
                            }
                            else br.push_back(ar[j--]);
                            continue;
                        }
                        if(ar[i] <= br.front()) {
                            br.push_front(ar[i++]);
                            continue;
                        }
                        else if(ar[i] >= br.back()) {
                            br.push_back(ar[i++]);
                            continue;
                        }
                        else if(ar[j] >= br.back()) {
                            br.push_back(ar[j--]);
                            continue;
                        }
                        else if(ar[j] <= br.front()) {
                            br.push_front(ar[j--]); continue;
                        }
                        else {
                            cout << "NO\n";
                            return;
                        }
                    }
                }
                else {
                    if(br.empty()) {
                        br.emplace_back(ar[j--]);
                    }
                    else {
                        if(ar[j] <= br.front()) {
                            br.push_front(ar[j--]);
                            continue;
                        }
                        else if(ar[j] >= br.back()) {
                            br.push_back(ar[j--]);
                            continue;
                        }
                        else if(ar[i] >= br.back()) {
                            br.push_back(ar[i++]);
                            continue;
                        }
                        else if(ar[i] <= br.front()) {
                            br.push_front(ar[i++]); continue;
                        }
                        else {
                            cout << "NO\n";
                            return;
                        }
                    }
                }
            }
            cout << "YES\n";
        };
        Test_Case();
    }
    return 0;
}

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 17:22:09
Judged At
2025-09-02 17:22:09
Judged By
Score
50
Total Time
3ms
Peak Memory
572.0 KiB