Cod sursa(job #774241)
| Utilizator | Data | 3 august 2012 21:19:36 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream in ("algsort.in");
ofstream out ("algsort.out");
struct comp
{
inline bool operator () (const int &a, const int &b){
return a > b;
}
};
priority_queue < int, vector <int>, comp > heap;
int main ()
{
int N, x;
in >> N;
while (N--){
in >> x;
heap.push (x);
}
while (!heap.empty ()){
out << heap.top () << " ";
heap.pop ();
}
return 0;
}