#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
typedef pair<int,int> ii;
using ll = long long ;
const int maxn = 1e5 + 1;
const int oo = 1e9 + 7;
const ll ooo = 2e18 + 7;
const int mod = 1e9 + 7;
int a[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//#ifndef ONLINE_JUDGE
//#define file ""
// freopen(file"inp","r",stdin);
// freopen(file"out","w",stdout);
//#endif //ONLINE_JUDGE
int n;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 2; i <= n; i+=2){
int k = i/2;
int mn = min({a[k], a[i], a[i+1]});
if(a[k] == mn) continue;
if(a[i] == mn)
{
swap(a[i], a[k]);
continue;
}
if(a[i] < a[k]) swap(a[i], a[k]), swap(a[k], a[i+1]);
else swap(a[k], a[i+1]);
}
for(int i = 1; i <= n; i++)
cout << a[i] << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |