Plants vs Zombies

시간 제한2초메모리 제한1024 MB

요약
좀비들이 시간에 따라 등장하고 가시덤불과 완두콩 발사기의 공격을 받으며 이동할 때, 각 좀비가 정확히 몇 초에 죽는지 구해 출력한다.
난이도

어려움10점 중 8점

유형
시뮬레이션, 힙, 누적 합, 정렬
정답자
아직 제출이 없습니다

문제

Prof. Pang is playing 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 t_it\_i with health point h_ih\_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 p_ip\_i and attack power a_ia\_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:

  1. When the xx-th second begins, the zombies whose t_it\_is equal xx appear at position 00.
  2. After that, for each appeared and alive zombie uu, it will suffer from the spikeweeds whose positions are in (P_u,P_u+V](P\_u, P\_u + V] where P_uP\_u is the current position of the uu-th zombie. So its health point will be decreased by ∑_1≤i≤m,P_u<p_i≤P_u+Va_i\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.
  3. 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 (1≤n,m≤105,1≤V,K,D≤1091\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 t_i,h_it\_i, h\_i (1≤t_i,h_i≤1091\le t\_i,h\_i \le 10^9) separated by a single space.

Each of the following mm lines contains two integers p_i,a_ip\_i, a\_i (1≤p_i,a_i≤1091\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.

힌트

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 2, suffers 4 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.

예제1

  1. 예제 1

    입력
    3 2 1 2 2
    1 11
    2 8
    1 1
    1 2
    2 4
    
    예상 출력
    2 3 1