#luoguP3488. [POI 2009] LYZ-Ice Skates
[POI 2009] LYZ-Ice Skates
题目描述
Byteasar runs a skate club. Its members meet on a regular basis and train    together, and they always use the club's ice-skates. The skate sizes are    (by convention) numbered from 
 to 
. Naturally, each club member has    some foot size, but that is not all to it! Skaters have skate size tolerance    factor 
: a skater with foot size 
 can wear skates with    sizes from 
 up to 
. It should be noted, though, that    no skater ever wears two skates of different size simultaneously.
To supply the club, Byteasar bought 
 pairs of ice-skates of each size,    i.e. from 
 to 
. As time passes, some people join the club, just as    some established members leave it. Byteasar worries if he will have enough    skates of appropriate size for every member at each training.
We assume that initially the club has no members at all. Byteasar will give    you a sequence of 
 events of the following form: 
 (new) members with    foot size 
 have joined/left the club. Right after each such event    Byteasar wants to know whether he has enough skates of appropriate size for    every club member. He asks you to write a programme that will check it for    him.
输入格式
The first line of the standard input contains four integers 
, 
,      
 and 
 (
, 
,      
, 
), separated by single spaces, that      denote, respectively: maximum skate size, number of events, number of      skate pairs of each size Byteasar initially bought, and the skate size      tolerance factor. The following 
 lines contain the sequence of 
      events, one per line. The 
-th line (for  should either contain the word      TAK (Polish for yes), or the word NIE (Polish for      no), depending on whether Byteasar has the skates of appropriate      size for every club member right after the 
-th event.
题目大意
滑冰俱乐部初始有 号码溜冰鞋各 双,已知 号脚的人可以穿 号码的鞋子。
现在有 次操作,每次两个数 ,表示来了 个 号脚的人, 为负则表示离开。在每次操作之后,你需要判断溜冰鞋是否足够。
输入格式:
第一行 个整数 。
接下来 行,每行两个整数 ,代表一次操作。
输出格式:
 行,每行一个字符串,若此次操作后满足题意则输出 TAK,否则输出 NIE。
数据范围:
$n\le 2\times 10^5,m\le 5\times 10^5,k\le 10^9,1\le r_i\le n-d,-10^9\le x_i\le 10^9,0\le d<n$
4 4 2 1
1 3
2 3
3 3
2 -1
TAK
TAK
NIE
TAK