/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 9ms 2.508 MiB
#3 Accepted 2ms 580.0 KiB
#4 Accepted 4ms 832.0 KiB
#5 Accepted 7ms 1.52 MiB
#6 Accepted 6ms 1.77 MiB
#7 Wrong Answer 1ms 532.0 KiB
#8 Wrong Answer 2ms 560.0 KiB

Code

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

#define ll long long
#define endl '\n'

const int nn = 1e5 + 17, mod = 1e9 + 7;
int n, A[nn];

bool pos(bool mxx, multiset<int> St) {
    for (int i = 1, j = n; i <= j; ) {
        int mn = *St.begin();
        int mx = *St.rbegin();
        if (mxx && A[i] == mx || !mxx && A[i] == mn) {
            St.erase(St.find(A[i]));
            i++;
            continue;
        }
        if (mxx && A[j] == mx || !mxx && A[j] == mn) {
            St.erase(St.find(A[j]));
            j--;
            continue;
        }
        return false;
    }
    return true;
}

void Try() {
    cin >> n;
    multiset<int>St;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        St.insert(A[i]);
    }
    
    if (pos(1, St) || pos(0, St)) cout << "YES\n";
    else cout << "NO\n";
    
}

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

    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        Try();
    }

}

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:26:01
Judged At
2025-09-01 06:26:01
Judged By
Score
60
Total Time
9ms
Peak Memory
2.508 MiB