Cod sursa(job #1655232)
| Utilizator | Data | 17 martie 2016 20:48:33 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
#include <queue>
#include <algorithm>
#include <limits.h>
#include <vector>
using namespace std;
ifstream in("algsort.in");
ofstream out("algsort.out");
vector<int> v(500003);
int main() {
int n;
int mx = INT_MAX;
in >> n;
for(int i = 0; i < n; i++) {
in >> v[i];
v[i] = mx - v[i];
}
make_heap(v.begin(), v.end());
for(int i = 0; i < n; i++) {
out << mx-v.front() << " ";
pop_heap(v.begin(), v.end());
v.pop_back();
}
}
