Cod sursa(job #2025893)

Utilizator Coroian_DavidCoroian David Coroian_David Data 23 septembrie 2017 13:48:13
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 2.41 kb
#include <bits/stdc++.h>

using namespace std;

typedef long long lint;

lint ax, ay, bx, by, cx, cy;

struct Point
{
    lint x, y;
};

const double pi = 4 * atan(1);

//typedef pair<long long, long long> Point;

lint ccw(Point A, Point B, Point C)
{
    return
    A.x * B.y - A.y * B.x +
    B.x * C.y - B.y * C.x +
    C.x * A.y - C.y * A.x;
}

lint dist(lint ax, lint ay, lint bx, lint by)
{
    lint dx = ax - bx;
    lint dy = ay - by;

    return dx * dx + dy * dy;
}

void readFile()
{
    scanf("%lld%lld", &ax, &ay);
    scanf("%lld%lld", &bx, &by);
    scanf("%lld%lld", &cx, &cy);


    if(dist(ax, ay, bx, by) != dist(bx, by, cx, cy) || ccw({ax, ay}, {bx, by}, {cx, cy}) == 0)
        printf("No\n");

    else
        printf("Yes\n");
}

struct elem
{
    int x, y;

    friend bool operator < (elem a, elem b)
    {
        return a.x < b.x;
    }

    /*friend bool operator > (elem a, elem b)
    {
        return a.x > b.x;
    }*/
};

struct cmp
{ int x;
    bool operator  () (const int &a, const int &b) const
    {
        x = 0;

        if(a < b)
            return true;

        return false;
    }
};



priority_queue<elem>aps;/*
#include <cstdio>
#include <algorithm>
*/
#define NX 500010
/*
using namespace std;
 */
int N, A[NX], B[NX];
 /*
bool cmp(int a, int b)
{
    if(a < b)
        return true;

    return false;
}*/

int main() {
    int i;

    freopen( "algsort.in", "r", stdin );
    freopen( "algsort.out", "w", stdout );

    scanf( "%d", &N );
    for( i = 1; i <= N; i++ )
        scanf( "%d", &A[i] );

   sort(A + 1, A + N + 1, cmp());

    for( i = 1; i <= N; i++ )
        printf( "%d ", A[i] );

    return 0;
}
/*
int main()
{
    cout<< pi <<'\n';

    cmp ceva;

    ceva(1,2);

    int v[100];
    int N = 10;
    sort(v+1, v+N+1, cmp());

    long double t1 = 0.123123123123123;
    long double t2 = 1000000000.123123123123123123123123123123;

    long double tt = 123e100000 + 0.123123123123123123123123D;

    cout<< acos( cos(pi) ) <<'\n';

    //cout.precision(1000);

    //cout<< fixed << t1 + 1 << '\n';
    //cout<< fixed << t2 + 1 << '\n';

   // cout<< ((1.0D  / 0) > math.inf) << '\n';

   // readFile();

    aps.push({999, 0});
    aps.push({9, 0});

  // cout << "+++";

    cout<< "+++++" << aps.top().x<< " " << aps.top().y;

    return 0;
}*/