Cod sursa(job #554188)
Utilizator | Data | 14 martie 2011 17:48:16 | |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
long n,i,a[500100];
freopen ("algsort.in","r",stdin);
freopen ("algsort.out","w",stdout);
scanf ("%d ",&n);
for (i=1;i<=n;i++) scanf ("%d",&a[i]);
make_heap(a+1,a+n+1);
sort_heap(a+1,a+n+1);
for (i=1; i<=n;i++) printf ("%d ",a[i]);
return 0;
}