#P7424. Bullet Board Break
Bullet Board Break
Bullet Board Break
A game is played with several wooden boards and bullets. The boards are placed horizontally (parallel to the x-axis) and each board is characterized by a horizontal interval and a durability. Specifically, the i-th board is located on the interval [Li, Ri] (inclusive) and will break (and disappear) once it has been hit by Si bullets. Bullets are fired one by one vertically (i.e. along the y-axis) at a fixed x-coordinate. A bullet will hit every board on its path if the bullet’s x-coordinate falls within the board’s interval. Note that if a bullet touches the edge of a board (i.e. equals Li or Ri), it is also counted as a hit.
Given the positions of n boards and m bullet firing positions (in the order they are fired), your task is to determine for each bullet how many boards break exactly as a result of that shot. A board breaks when the cumulative number of hits reaches exactly Si (expressed in LaTeX as \(S_i\)). Boards that have already broken are no longer hit by subsequent bullets.
inputFormat
The first line contains two integers n and m, the number of boards and the number of bullets, respectively.
Then follow n lines, each containing three integers Li, Ri and Si, representing the left and right boundaries of the i-th board and the number of hits needed to break it.
Then follow m lines, each containing an integer representing the x-coordinate at which the bullet is fired.
outputFormat
Output m lines. The j-th line should contain a single integer, indicating the number of boards that break exactly when the j-th bullet is fired.
sample
3 5
1 3 2
2 4 1
0 2 3
2
1
4
3
2
1
1
0
0
1
</p>