Pagini recente » Cod sursa (job #1169432) | Statistici Ionut Anghelina (ionanghelina) | Cod sursa (job #869896) | Istoria paginii runda/pregatire_oji_11-12_/clasament | Cod sursa (job #1611833)
// 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;
}