Submission #93252

# Submission time Handle Problem Language Result Execution time Memory
93252 2019-01-07T11:04:29 Z popovicirobert Swap (BOI16_swap) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int INF = 1e9;
const int MAXN = (int) 1e5;

int arr[3 * MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    for(i = n + 1; i <= 2 * n + 5; i++) {
        arr[i] = INF;
    }
    for(i = 2; i <= n; i += 2) {
        int pos = i / 2;
        if(arr[i] < arr[i + 1]) {
            swap(arr[i], arr[pos]);
        }
        else {
            swap(arr[i + 1], arr[pos]);
        }
        if(arr[i] > arr[i + 1] && min(arr[2 * i], arr[2 * i + 1]) > arr[i + 1]) {
            swap(arr[i], arr[i + 1]);
        }
    }
    for(i = 1; i <= n; i++) {
        cout << arr[i] << " ";
    }
    //cin.close();
    //cout.close();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -