//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
const int N = 500001;
using namespace std;
ll n, p[N], m, a, b, c;
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> p[i];
}
p[n + 1] = 1e9;
p[n + 2] = 1e9;
for (int i = 1; i <= n / 2; i++){
if (i % 2 == 1){
if (min (p[i + i], p[i + i + 1]) < p[i]){
if (p[i + i] < p[i + i + 1]){
swap (p[i], p[i + i]);
}
else{
swap (p[i], p[i + i + 1]);
}
if (p[i + i] > p[i + i + 1]){
swap (p[i + i], p[i + i + 1]);
}
}
}
else{
if (min (p[i + i], p[i + i + 1]) < p[i]){
if (p[i] < p[i + 1]){
swap (p[i], p[i + 1]);
}
if (p[i + i] < p[i + i + 1]){
swap (p[i], p[i + i]);
}
else{
swap (p[i], p[i + i + 1]);
}
if (p[i + i] > p[i + i + 1]){
swap (p[i + i], p[i + i + 1]);
}
}
}
// for (int y = 1; y <= n; y++){
// cout << p[y] << ' ';
// }
// cout << '\n';
}
for (int i = 1; i <= n; i++){
cout << p[i] << ' ';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |