thought that the microwave situation at the University of Waterloo would be better than that at Pierre Elliott Trudeau High School, but he was wrong! Microwaves at the Waterloo MC (Mainland China) building are spread all throughout the building, and of course, there is always a line of students waiting to microwave their lunches.
The MC building contains
Because of the unbearable circumstances,
Constraints
For all subtasks:
Subtask 1 [15%]
Up to
Subtask 2 [35%]
Up to
Subtask 3 [50%]
No additional constraints.
Input Specification
The first line will contain 3 space-separated integers:
The next line of input will contain
Output Specification
Output a single integer, the maximum number of microwaves that
can destroy.Sample Input
5 5 2
3 2 3 5 1
1 2 2
2 3 3
1 3 4
3 4 3
3 5 5
Sample Output
13
Explanation for Sample Output
can use his first Atomic Blast in room 1 in order to destroy all microwaves in rooms 1 and 2. He then can use two more Atomic Blasts to destroy separately all microwaves in rooms 3 and 4.
Comments