
ZOJ Problem Set  2041
N gangsters are going to a restaurant. The ith gangster comes at the time
Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness
expressed by the integers in the range [0, K]. The state of openness can change
by one in one unit of time; i.e. it either opens by one, closes by one or remains
the same. At the initial moment of time the door is closed (state 0). The ith
gangster enters the restaurant only if the door is opened specially for him,
i.e. when the state of openness coincides with his stoutness Si. If at the moment
of time when the gangster comes to the restaurant the state of openness is not
equal to his stoutness, then the gangster goes away and never returns.
All values in the input file are integers.
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks. The output format consists of N output blocks. There is a blank line between
output blocks.
2 2 17 100
26 0 Source: Northeastern Europe 1998 