Wrong Answer
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