Submission #56200

# Submission time Handle Problem Language Result Execution time Memory
56200 2018-07-10T08:44:14 Z 노영훈(#1580) Swap (BOI16_swap) C++11
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=500010, inf=2e9;

int n;
int A[MX];


int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i];
    for(int i=1; i<=n; i++){
        int a=2*i, b=2*i+1;
        if(a>n) break;
        if(b>n) { if(A[a]<A[i]) swap(A[a], A[i]); break; }

        if(A[i]>A[a]) swap(A[i], A[a]);
        if(A[i]>A[b]) swap(A[i], A[b]);

        if(A[a]>A[b]) swap(A[a], A[b]);

        int x=A[a];
        if(a*2<=n) x=min(x, A[a*2]);
        if(a*2+1<=n) x=min(x, A[a*2+1]);

        if(x!=A[a]) swap(A[a], A[b]);
    }
    for(int i=1; i<=n; i++) cout<<A[i]<<' ';
    cout<<'\n';
    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 -