Problems > Area of a Polygon

Area of a Polygon

Difficulty: 1500 2000 ms 128 MB

geometry

The vertices of a simple polygon are listed in order. Print its area, which is always an integer or half-integer — output with one decimal digit (.0 or .5).

Input: the first line has N; the next N lines have the vertices in order.

Output: the polygon's area with exactly one decimal.

Constraints:

  • 3 ≤ N ≤ 104
  • |coordinates| ≤ 104

Sample Tests

Input 1
3
0 0
4 0
0 3
Output 1
6.0
Input 2
4
0 0
2 0
2 2
0 2
Output 2
4.0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.