Catch popcorn, not boulders!
If a boulder hits you, you'll spill some popcorn!
Snack Attack is a four player minigame in Super Mario Party and you can view how the game is actually played here.
The goal of the game is to catch as many kernels of popcorn that fall from the sky using the cups on top of each players' head. In addition to popcorn, boulders will fall from the sky. The boulders are too big to catch with the cup, and so if hit by one, the player will lose half of their current popcorn kernels in the cup.
The original game is set in a circular area, but in this problem we will
assume it is a square grid for simplicity. If a popcorn kernel falls
onto some cell

Given the positions of all falling popcorns and boulders, the time that each will fall, and the initial position of the player, we want to know what is the maximum amount of popcorn this player can catch if they play through until the end.
Input Specification
The first line of the input contains three integers,
The next line contains two integers
The next
The next
There won't be any boulders or popcorns at time 0.
At the same time, there won't be both popcorn and boulders falling into the same position. There also won't be two boulders falling into the same position at the same time.
There CAN be multiple popcorn kernels falling into the same position at the same time.
Output Specification
The output only contains 1 integer, which is the maximum number of popcorn kernels the player can get.
Sample Input
5 4 2
2 2
2 3 1
1 4 3
1 2 1
1 0 3
2 4 2
1 3 2
Sample Output
2
Explanation for Sample Output
For the sample test case, one of the best solutions is shown as follows:
Source of pictures and descriptions: https://www.mariowiki.com/Snack_Attack. You can also find more details about the game from this site.
Scoring
For 50% of the test data,
For 100% of the test data,
For 15% of the test data,
There are 20 test cases, 5 points each.
Comments