IITWPC4E - Maggu’s Solar Panels
Summer is here and so is the season of powercuts, everybody here in IITK has installed there own solar panels over the roof. Now while setting panels, nobody cared of there panel was overlapping with others, the end result looks something likes the one shown below.
Clearly, a panel cannot produce electricity from the part where light does not fall. Our Maggu has been given the task of estimating the total electricity output from panels from Hall Office. This task is haunting him. Even Coder cannot do it alone, he needs your help. Assume that all panels produce the same power per unit area and that the area not directly under the sun does not produce any electricity.
You need to print the power that will be produced given the end points of rectangular panels and the power per unit area that panels produce.
Note: The sides of the panel will be parallel to the X-axis or Y-axis. Meaning, panels will never be tilted. Hence, a panel can be represented by 4 integers x, y, X and Y. Where (x, y) is the co-ordinate of the bottom left corner of the panel and (X, Y) is the co-ordinate of the top right corner of the panel.
Input
First line contains two space separated integers N, number of solar panels and R, power per unit area. Next N lines contains the description of N panels. Each line containing 4 space separates integers x, y, X and Y respectively.
Output
You need to output a single integer, the total power that can be generated.
Constraints
-10^8 <= x <= X <= 10^8
-10^8 <= y <= Y <= 10^8
1 <= N <= 100000
1 <= R <= 100
Example
Input: 3 2 -6 0 3 6 0 4 6 10 4 -2 9 6 Output: 240
Added by: | praveen123 |
Date: | 2014-01-31 |
Time limit: | 3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | IITK ACA CSE online judge |