#P9515. 「JOC-1A」限时签到

「JOC-1A」限时签到

Background

Even if I cannot find the youth outside my body,

I still have to throw myself against the late years within me.

But where is the dark night?

Now there are no stars, no moonlight, and thus no faintness of laughter or the flight of love;

The young people are safe, yet before my eyes there is not even a real dark night.

Despair being emptiness is exactly the same as hope!

——@duanfeitong, excerpt from Lu Xun's Hope.

Problem Description

You are now on a straight road. We may treat this road as a number line. You are currently at the origin of the number line. In addition, there are nn check-in points. The coordinate of the ii-th check-in point is xix_i, and it will start operating at the aia_i-th moment after you set off. You can enter and check in at a check-in point only after it has started operating (the time for checking in can be ignored). In each moment, you can move at most 11 unit. You must arrive at the point with coordinate ff at moment tt or earlier (ftf\le t). No matter when you arrive at point ff within the allowed time, starting from moment tt you must stay at point ff forever. Find the maximum number of check-in points you can check in at. Note that you do not need to check in according to the numbering order of the check-in points.

Input Format

There are n+1n+1 lines in total.

The first line contains three integers nn, tt, and ff.

The next nn lines each contain two integers xix_i and aia_i.

Output Format

One line containing a non-negative integer, representing the maximum number of check-in points you can check in at.

3 20 10
7 18
3 5
5 0
2

Hint

Explanation for Sample 1\small\text{1}

One feasible plan is as follows: check in at the third check-in point at moment 55, then check in at the second check-in point at moment 77, and finally arrive at the destination at moment 1414. It can be proven that at most 22 check-in points can be checked in at.

Constraints

This problem uses bundled testdata.

Subtask\textbf{Subtask} Number\textbf{Number} Special conditions\textbf{Special conditions} Points\textbf{Points} Limit\textbf{Limit}
11 121-2 n10n\leq 10 1010 1s,128MB\small\texttt{1s,128MB}
22 343-4 n5×103n\leq 5\times 10^3 1515
33 55 n106n\leq 10^6 2525
44 676-7 f105f\leq 10^5 2020 500ms,128MB\small\texttt{500ms,128MB}
55 898-9 n106n\leq 10^6 3030 150ms,10MB\small\texttt{150ms,10MB}

For 100%100\% of the data, 1n1061\leq n\leq 10^6, 0ft10180\leq f\leq t\leq 10^{18}, 0xif0\leq x_i\leq f, 0ait0\leq a_i\leq t, and it is not guaranteed that the coordinates of the check-in points are all distinct.

Please note: since the input size is too large when nn is close to 10710^7, we decided to adjust the time limit and memory limit on data with n106n\leq 10^6 to replace the evaluation on data with n107n\leq 10^7.

Please note that the input size of this problem is large. It is recommended to use a fast input method.


In my eternal memory,

you smile innocently.

In my young heart,

you are a spark that keeps burning.

——@duanfeitong, excerpt from Qi Zi's Childhood.

Translated by ChatGPT 5