# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
107762 |
2019-04-25T17:05:03 Z |
Kepperoni |
Swap (BOI16_swap) |
C++14 |
|
2 ms |
384 KB |
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 2e5 + 10;
int n;
int a[MAXN];
bool hm[MAXN];
int main(){
cin >> n;
for(int i=1; i<=n; i++)
cin >> a[i];
for(int i=1; i*2<=n; i++) hm[i]=1;
for(int i=2; i<=n; i+=2){
if(i == n){
if(a[i/2] > a[i]) swap(a[i/2], a[i]);
} else {
if(a[i] < a[i/2] && a[i] < a[i+1]) swap(a[i/2], a[i+1]);
else if(a[i+1] < a[i/2]){
if(hm[i] && !hm[i+1]){
if(a[i] < a[i/2]) swap(a[i], a[i/2]);
} else {
if(a[i] > a[i/2]) swap(a[i], a[i/2]);
}
swap(a[i+1], a[i/2]);
}
}
}
for(int i=1; i<=n; i++) cout << a[i] << " ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |