Cod sursa(job #3032919)

Utilizator RolandPetreanPetrean Roland RolandPetrean Data 23 martie 2023 08:42:36
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

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

int main() {
  int n;
  fin>>n;

  vector<int> x(n), y(n);
  for (int i=0; i<n; ++i) fin>>x[i]>>y[i];

  double a=0;
  for (int i=0; i<n; ++i) {
    int j=(i+1)%n;
    a += (double)x[i]*y[j] - (double)x[j]*y[i];
  }
  a /= 2;

  fout<<fixed<<abs(a);
}