A simple polygon has n corners listed in order around its boundary, either clockwise or counterclockwise. Its edges never cross and touch only at neighbouring corners. Print twice its area. The area is always a whole number when doubled, so the answer is an integer.
The first line has n. Each of the next n lines has the coordinates x y of one corner, in order around the boundary.
Print one integer: twice the area of the polygon.
3 <= n <= 200000 |x|, |y| <= 10^9 The answer is at most 8 x 10^18, which fits in a signed 64-bit integer.
1000 ms256 MB
4 0 0 4 0 4 4 0 4
32
A 4 by 4 square has area 16, so twice the area is 32.
6 0 0 2 0 2 1 1 1 1 2 0 2
6
An L-shaped hexagon made of three unit squares has area 3, so the answer is 6.