Ants and Sugar

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

JOI-kun is a biologist. He plans an experiment on ants and sugar.

JOI-kun’s experiment takes place on a long straight stick of length 1,000,000,0001\\,000\\,000\\,000 (=109= 10^9). It is placed from the left to the right. The point on the stick which is located at a distance xx from the leftmost point is called the point of coordinate xx.

Now, nothing is placed on the stick. JOI-kun will perform the QQ operations. The ii-th operation (1iQ1 ≤ i ≤ Q) is specified by the three integers T_iT\_i, X_iX\_i, A_iA\_i. They mean as follows.

  • If T_i=1T\_i = 1, JOI-kun places A_iA\_i ants at the point of coordinate X_iX\_i.
  • If T_i=2T\_i = 2, JOI-kun places A_iA\_i sugar cubes at the point of coordinate X_iX\_i.

Since ants and sugar cubes are very small, it is possible to place some of them at the same point. JOI-kun may perform several operations at the same point.

The ants used in this experiment have curious properties. Precisely, if JOI-kun claps hands, every ant will do the following.

  • If there is a sugar cube at a distance less than or equal to LL from the ant, the ant will choose any one of them and eat it.

It may happen that several ants eat the same sugar cube at the same time.

For every kk (1kQ1 ≤ k ≤ Q), JOI-kun wants to know the answer to the following question.

  • Assume that JOI-kun claps hands after the kk-th operation. What is the maximum possible number of sugar cubes eaten by at least one ant?

Write a program which, given the operations performed by JOI-kun and the value of LL, answers to JOI-kun’s questions for all kk.

Note that JOI-kun does not clap hands actually. Therefore, the positions of the ants do not change, and the sugar cubes are not eaten.

입력

Read the following data from the standard input. Given values are all integers.

\begin{align\*}& Q \\, L \\\ & T\_1 \\, X\_1 \\, A\_1 \\\ & T\_2 \\, X\_2 \\, A\_2 \\\ & \vdots \\\ & T\_Q \\, X\_Q \\, A\_Q \end{align\*}

출력

Write QQ lines to the standard output. The kk-th line (1kQ1 ≤ k ≤ Q) of output should contain the maximum possible number of sugar cubes eaten by at least one ant if JOI-kun claps hands after the kk-th operation.

제한

  • 1Q500,0001 ≤ Q ≤ 500\\,000.
  • 1L1,000,000,0001 ≤ L ≤ 1\\,000\\,000\\,000 (=109= 10^9).
  • T_iT\_i is 11 or 22 (1iQ1 ≤ i ≤ Q).
  • 0X_i1,000,000,0000 ≤ X\_i ≤ 1\\,000\\,000\\,000 (=109= 10^9) (1iQ1 ≤ i ≤ Q).
  • 1A_i1,000,000,0001 ≤ A\_i ≤ 1\\,000\\,000\\,000 (=109= 10^9) (1iQ1 ≤ i ≤ Q).