Cod sursa(job #1611833)
Utilizator | Vali Deaconu Vali_Deaconu | Data | 24 februarie 2016 14:48:31 |
---|---|---|---|
Problema | Sortare prin comparare | Scor | 60 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
// Heapsort: O(log n)
# include <fstream>
# include <set>
using namespace std;
ifstream fin("algsort.in");
ofstream fout("algsort.out");
multiset<int> heap;
int n, x;
int main() {
fin >> n;
while (n--) {
fin >> x;
heap.insert(x);
}
for (multiset<int>::iterator it = heap.begin(); it != heap.end(); ++it)
fout << *it << " ";
fin.close();
fout.close();
return 0;
}