#P3488. Skate Club Assignments
Skate Club Assignments
Skate Club Assignments
Byteasar runs a skate club. The available ice-skates come in sizes numbered from \(L\) to \(R\). Each member of the club has a foot size \(f\) and a tolerance factor \(\delta\); a member with foot size \(f\) can wear any skate whose size is in the range \(\max(L, f-\delta)\) to \(\min(R, f+\delta)\). Note that no member wears two skates of different sizes simultaneously.
To equip his club, Byteasar buys \(K\) pairs of skates for each size from \(L\) to \(R\). Initially the club has no members. Then Byteasar receives a sequence of \(Q\) events. Each event is one of the following forms:
+ f c
: indicating thatc
new members with foot size \(f\) have joined the club.- f c
: indicating thatc
members with foot size \(f\) have left the club.
After each event, Byteasar needs to know whether it is possible to assign a pair of skates of an appropriate size to every club member. An assignment is valid if each member receives a skate whose size is within his/her allowable interval and no skate pair is used by more than one member.
Your task is to help Byteasar determine, after each event, whether a valid assignment exists. Print YES
if it exists and NO
otherwise.
inputFormat
The input begins with a line containing five integers \(L, R, \delta, K, Q\) where:
- \(L\) and \(R\) (\(L \le R\)) denote the minimum and maximum skate sizes.
- \(\delta\) is the tolerance factor.
- \(K\) is the number of pairs of skates available for each size.
- \(Q\) is the number of events.
Each of the next \(Q\) lines describes an event in the format:
op f c
Here, op
is either '+' (for members joining) or '-' (for members leaving), \(f\) is the foot size of the member(s) and \(c\) is the number of members involved in the event.
It is guaranteed that the events are valid (i.e. no more members leave than are present).
outputFormat
After each event, print a single line containing YES
if it is possible to assign an appropriate pair of skates to every club member, or NO
otherwise.
sample
36 42 1 2 3
+ 37 2
+ 40 1
- 37 1
YES
YES
YES
</p>