Cod sursa(job #3124540)

Utilizator divadddDavid Curca divaddd Data 29 aprilie 2023 12:00:02
Problema Sortare prin comparare Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

ordered_map<int, int> my_map;
int n,x;

ifstream fin("algsort.in");
ofstream fout("algsort.out");

int main()
{
    fin >> n;
    for(int i = 1; i <= n; i++){
        fin >> x;
        my_map[x]++;
    }
    for(auto [val, cnt]: my_map){
        for(int i = 1; i <= cnt; i++){
            fout << val << " ";
        }
    }
    return 0;
}