Cod sursa(job #577256)

Utilizator TeodoraTanaseTeodora Tanase TeodoraTanase Data 9 aprilie 2011 22:22:12
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.6 kb
#include <cstdio>
#include <queue>

using namespace std;

struct cmp
{
    bool operator()(const int &a,const int &b)const
    {
        if (a<b)
            return false;
        return true;
    }
};

priority_queue <int, vector<int>, cmp> d;

int main()
{
    freopen ("algsort.in","r",stdin);
    freopen ("algsort.out","w",stdout);
    int n, x; scanf ("%d ",&n);
    for (int i=1; i<=n; ++i)
    {
        scanf ("%d ",&x);
        d.push(x);
    }
    for (int i=1; i<=n; ++i)
    {
        printf ("%d ",d.top());
        d.pop();
    }
    printf ("\n");
    return 0;
}