Cod sursa(job #2591387)
Utilizator | Dumitrescu Gheorghe k2e0e0w3q | Data | 30 martie 2020 13:38:35 |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
class cmp {
public:
bool operator () (const int &a, const int &b) {
return a>b;
}
};
int main () {
ifstream fin ("algsort.in");
ofstream fout ("algsort.out");
priority_queue <int, vector <int>, cmp> PQ;
int n, x;
for (fin >> n; n; n--) {
fin >> x;
PQ.push(x);
}
while (!PQ.empty()) {
fout << PQ.top() << ' ';
PQ.pop();
}
return 0;
}