LCC '24 Contest 3 J1 - Icebergs

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Bob the penguin is part of a special species of penguins that can fly! He has recently discovered a peculiar fact: all the icebergs (even the floating ones!!) that he and his fellow flying penguin inhabit can be modelled as rectangles! In particular, Bob the penguin is examining a single iceberg with coordinates (x_1,y_1), (x_2,y_2), (x_3,y_3), (x_4,y_4), in clockwise order of vertices, starting from the top left. He would like to know the area of the iceberg that is located above the x-axis, or in other words, the area of the region above the line y=0. However, since Bob the penguin isn't able to program this problem with his flippers, he asks you to help code this problem!

Input Specification

There will be 4 lines of input, with the i^{th} line containing two space-separated integers x_i, y_i.

Output Specification

Output one integer, representing the total area of the iceberg that is located above the x-axis.

Constraints

For all subtasks, -10^3 \leq x_i \leq 10^3

Subtask 1 [50%]

All coordinates have a non-negative y value, where 0 \leq y_i \leq 10^3.

Subtask 2 [50%]

-10^3 \leq y_i \leq 10^3

Sample Input

-3 2
7 2
7 -6
-3 -6

Sample Output

20

Sample Explanation

As observed in the graph, the portion above the x-axis has width 10 and height 2.


Comments

There are no comments at the moment.