Black Boxes
Problem Statement
You have a two-dimensional plane, initially the plane is white. On this two-dimensional plane you will perform n queries on this plane:
- Each query is given l, r and h
- Colour the rectangle (l,0) to (r,h) At the end of all n queries, determine the total area which is black.
Input Format
Your first line will contain a single integer n. Your next n lines will contain three integers each, representing l, r and h respectively.
Output Format
Output the total number of area that is coloured black after performing all queries.
Constraints
- 1≤n≤105
- 0≤l≤r≤109
- 1≤h≤109
Sample Cases
3
0 1 1
0 3 3
2 4 2
11
2
0 100000 100000
1 99999 100001
10000099998
Template
n = int(input())
rectangles = [tuple(map(int, input().split())) for _ in range(n)]
# print your output
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.