Cod sursa(job #2084719)

Utilizator dragomirmanuelDragomir Manuel dragomirmanuel Data 9 decembrie 2017 11:41:17
Problema Aria Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.66 kb
#include <iostream>
#include <cstdio>

#define x first
#define y second

using namespace std;

const int NMax = 100002 ;

int N;
pair < double, double > v[NMax];

void Read()
{
    scanf("%d", &N);

    for(int i=1; i<=N; ++i)
        scanf("%lf %lf", &v[i].x, &v[i].y);
}

double Solve()
{
    double rez = 0;

    for(int i=1; i<N; ++i)
        rez += v[i].x*v[i+1].y - v[i+1].x*v[i].y;

    rez+=v[N].x*v[1].y-v[1].x*v[N].y;

    if( rez < 0)
        rez = -rez;

    return rez;
}

int main()
{
    freopen("aria.in", "r", stdin);
    freopen("aria.out", "w", stdout);

    Read();
    printf("%lf\n", Solve()/2);
    return 0;
}