luogu#P10824. [EC Final 2020] Plants vs Zombies

[EC Final 2020] Plants vs Zombies

题目描述

Prof. Pang is playing Plants vs Zombies\textit{Plants vs Zombies}.

Imagine that the game is played on a number axis. The following are the elements in the game:

  • nn zombies. The ii-th zombie appears at 00 on the number axis at time tit_i with health point hih_i. The zombies have the same moving speed VV and they all move to the right.
  • mm spikeweeds. The ii-th spikeweed is of position pip_i and attack power aia_i.
  • One peashooter at the position of 1010010^{100}. It shoots KK peas of attack power DD every second.

Every second in the game is processed as follows:

  • When the xx-th second begins, the zombies whose tit_is equal xx appear at position 00.
  • After that, for each appeared and alive zombie uu, it will suffer from the spikeweeds whose positions are in (Pu,Pu+V](P_u, P_u + V] where PuP_u is the current position of the uu-th zombie. So its health point will be decreased by $\sum\limits_{1\le i\le m, P_u < p_i \le P_u + V} a_i$. The zombie dies if its health point is no more than zero. Otherwise, it is still alive and its position will be increased by VV.
  • When the xx-th second ends, the peashooter shoots KK peas in a row. For each pea, it will hit the zombie that is alive and of the maximum position currently. If there are multiple zombies of the maximum position, the pea hits the one of the minimum index. The health point of the zombie being hit decreases by DD. This zombie dies if its health point is decreased to some value no more than 00. The peas are processed one by one, not simultaneously. (For example, if a zombie is killed by the first pea, the second pea cannot hit it since it dies before the second pea is shot.) If no alive zombie exists, the remain peas will hit nothing.

Prof. Pang wants to know the death time (in seconds) of all the nn zombies.

输入格式

The first line contains five integers n,m,V,K,Dn,m,V,K,D (1n,m105,1V,K,D1091\le n,m \le 10^5, 1\le V,K,D \le 10^9) separated by single spaces.

Each of the following nn lines contains two integers ti,hit_i, h_i (1ti,hi1091\le t_i,h_i \le 10^9) separated by a single space.

Each of the following mm lines contains two integers pi,aip_i, a_i (1pi,ai1091\le p_i,a_i \le 10^9) separated by a single space.

输出格式

Output one line containing nn integers, where the ii-th integer denotes the death time (in seconds) of the ii-th zombie.

3 2 1 2 2
1 11
2 8
1 1
1 2
2 4
2 3 1

提示

During the first second:

  • The first zombie appears and then moves to position 1. It suffers 66 damage points (22 from the first spikeweed, 44 from the two peas).
  • The third zombie appears and then moves to position 1. It suffers 22 damage points (from the first spikeweed) and dies (since its health point becomes 1-1).

During the second second:

  • The first zombie moves to position 22 and suffers 66 damage points (44 from the second spikeweed, 22 from the first pea) and dies (since its health point becomes 1-1).
  • The second zombie appears and then moves to position 11. It suffers 44 damage points (22 from the first spikeweed, 22 from the second pea).

During the third second:

  • The second zombie moves to position 22, suffers 44 damage points (44 from the second spikeweed) and dies (since its health point becomes 00).
  • The peas hit no zombie during this second.

So the death times of the zombies are 22, 33, 11, respectively.