CF76F.Tourist
提高+/省选-
通过率:0%
时间限制:0.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Tourist walks along the X axis. He can choose either of two directions and any speed not exceeding V. He can also stand without moving anywhere. He knows from newspapers that at time _t_1 in the point with coordinate _x_1 an interesting event will occur, at time _t_2 in the point with coordinate _x_2 — another one, and so on up to (x__n, t__n). Interesting events are short so we can assume they are immediate. Event i counts visited if at time t__i tourist was at point with coordinate x__i.
Write program tourist that will find maximum number of events tourist if:
- at the beginning (when time is equal to 0) tourist appears at point 0,
- tourist can choose initial point for himself.
Yes, you should answer on two similar but different questions.
游客沿 X 轴行走。他可任选两个方向之一,且速度不超过 V;他也可以静止不动。他从报纸上得知:在时刻 _t_₁,坐标为 _x_₁ 的位置将发生一个有趣的事件;在时刻 _t_₂,坐标为 _x_₂ 的位置将发生另一个有趣的事件;……依此类推,直至 (x__n, t__n)。这些有趣事件持续时间极短,因此可视为瞬时发生。若游客在时刻 t__i 恰好位于坐标 x__i 处,则称事件 i 被访问。
请编写程序 tourist,求出游客最多能访问的事件数量,满足以下条件:
- 初始时刻(时间为 0)时,游客出现在坐标 0 处;
- 游客可自行选择初始位置。
是的,您需要回答两个相似但不同的问题。
输入格式
The first line of input contains single integer number N (1 ≤ N ≤ 100000) — number of interesting events. The following N lines contain two integers x__i and t__i — coordinate and time of the i-th event. The last line of the input contains integer V — maximum speed of the tourist. All x__i will be within range - 2·108 ≤ x__i ≤ 2·108, all t__i will be between 1 and 2·106 inclusive. V will be positive and will not exceed 1000. The input may contain events that happen at the same time or in the same place but not in the same place at the same time.
输入的第一行包含一个整数 N(1≤N≤100000),表示有趣事件的数量。接下来的 N 行每行包含两个整数 xi 和 ti,分别表示第 i 个事件发生的坐标和时间。输入的最后一行包含一个整数 V,表示游客的最大速度。所有 xi 均满足 −2⋅108≤xi≤2⋅108,所有 ti 均满足 1≤ti≤2⋅106。V 为正整数且不超过 1000。输入中可能包含发生在同一时刻或同一地点的事件,但不会出现同时同地发生的事件。
输出格式
The only line of the output should contain two space-sepatated integers — maximum number of events tourist can visit in he starts moving from point 0 at time 0, and maximum number of events tourist can visit if he chooses the initial point for himself.
输出仅包含一行,应包含两个以空格分隔的整数——第一个为游客从位置 0、时刻 0 开始移动时最多能参观的事件数量;第二个为游客可自行选择初始位置时最多能参观的事件数量。
输入输出样例
输入#1
3 -1 1 42 7 40 8 2
输出#1
1 2
输入解题思路,AI测评打分。不知道怎么写?