Cod sursa(job #655556)
| Utilizator | Data | 2 ianuarie 2012 20:42:00 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
// Heapsort de 100 puncte (STL)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f( "algsort.in" ); ofstream g( "algsort.out" );
vector< int > V;
int N, x;
int main()
{ f >> N;
for(int i = 0; i < N; i++ ) {f >> x; V.push_back( x );}
make_heap( V.begin(), V.end() );
sort_heap( V.begin(), V.end() );
for(int i = 0; i < N; i++ ) g << V[i] << ' ';
g<<'\n'; g.close(); return 0;
}
