Cod sursa(job #1623676)
| Utilizator | Data | 1 martie 2016 20:57:22 | |
|---|---|---|---|
| Problema | Sortare prin comparare | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> v;
int main()
{
ifstream f("algsort.in");
ofstream g("algsort.out");
int n, x; f >> n;
for(int i = 1; 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 < v.size(); i ++) g << v[i] << " ";
g << "\n";
return 0;
}
