163. Polygon Area
MediumGeometryShoelace
Print twice the area of a simple polygon given its vertices in order (this is always an integer).
Input format
Line 1: n Next n lines: x y
Output format
2 × area
Example 1
Input
4 0 0 4 0 4 3 0 3
Output
24
Example 2
Input
3 0 0 1 0 0 1
Output
1
Constraints
3 ≤ n ≤ 10⁵ |x|, |y| ≤ 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…