Area of a Polygon
Statement
Goal
Given N coordinate pairs, determine the area of the (not necessarily convex) polygon formed by connecting the points in order and connecting the first and last point. The polygon will never self intersect.Input
Line 1: A positive integer N.
Next N lines: Two integers separated by space, a coordinate pair.
Next N lines: Two integers separated by space, a coordinate pair.
Output
A single integer which is the area of the polygon.
Constraints
2 < N < 21
Example
Input
4 0 0 5 0 5 6 0 6
Output
30
Game modes
Fastest
Test cases
Rectangle Test
Input
4
0 0
5 0
5 6
0 6
Output
30
Validator 1 Validator
Input
4
0 0
6 0
6 6
0 6
Output
36
Weird Test
Input
4
4 10
4 3
11 2
9 7
Output
34
Validator 2 Validator
Input
4
7 8
4 3
11 2
9 7
Output
23
Weirder Test
Input
5
2 4
5 9
3 11
2 10
-2 6
Output
23
Validator 3 Validator
Input
5
2 4
5 11
3 13
2 10
0 9
Output
19
Lots of vertices Test
Input
9
2 0
5 4
3 7
2 10
0 9
1 8
-10 7
-5 5
-3 1
Output
68
Validator 4 Validator
Input
9
2 0
5 4
3 7
2 10
0 9
1 8
-10 7
-5 3
-3 1
Output
75
Solution language
Solution
Stub generator input