hiho week 205 register

Ended

Participants:179

Verdict:Accepted
Score:100 / 100
Submitted:2018-06-04 00:33:42

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<bits/stdc++.h>
using namespace std;
int n;
int A[110];
int minheap(int x,int y)
{
    int i,j,k,l;
    k=A[j=x];
    for(i=x+1;i<=y;i++)if(A[i]<k)k=A[j=i];
    if(x>1 || y<n)cout<<' ';
    cout<<k;
    if(j>x)minheap(x,j-1);
    if(j<y)minheap(j+1,y);
    return 0;
}
int main()
{
    int i,j,k,l;
    while(cin>>n)
    {
        for(i=1;i<=n;i++)cin>>A[i];
        minheap(1,n);
        cout<<endl;
    }
    return 0;
} 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX