#abc265b. B - Explore

B - Explore

Score : 200200 points

问题描述

Takahashi 正在一款电子游戏中探索一个洞穴。

该洞穴由 NN 个房间按一行排列。从入口开始,房间依次编号为 Room 1,2,,N1,2,\ldots,N

Takahashi 起初位于 Room 11,并且有 时间限制TT
对于每个 1iN11 \leq i \leq N-1,他可以消耗时间为 AiA_i 从第 ii 个房间移动到第 (i+1)(i+1) 个房间。这是在房间之间移动的唯一方式。他不能做出导致时间限制变为 00 或更少的移动。

洞穴中有 MM 个奖励房间。第 ii 个奖励房间是 Room XiX_i;当他到达这个房间时,时间限制会增加 YiY_i

Takahashi 能否到达 Room NN

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi is exploring a cave in a video game.

The cave consists of NN rooms arranged in a row. The rooms are numbered Room 1,2,,N1,2,\ldots,N from the entrance.

Takahashi is initially in Room 11, and the time limit is TT.
For each 1iN11 \leq i \leq N-1, he may consume a time of AiA_i to move from Room ii to Room (i+1)(i+1). There is no other way to move between rooms. He cannot make a move that makes the time limit 00 or less.

There are MM bonus rooms in the cave. The ii-th bonus room is Room XiX_i; when he arrives at the room, the time limit increases by YiY_i.

Can Takahashi reach Room NN?

Constraints

  • 2N1052 \leq N \leq 10^5
  • 0MN20 \leq M \leq N-2
  • 1T1091 \leq T \leq 10^9
  • 1Ai1091 \leq A_i \leq 10^9
  • 1<X1<<XM<N1 < X_1 < \ldots < X_M < N
  • 1Yi1091 \leq Y_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM TT

A1A_1 A2A_2 \ldots AN1A_{N-1}

X1X_1 Y1Y_1

X2X_2 Y2Y_2

\vdots

XMX_M YMY_M

Output

If Takahashi can reach Room NN, print Yes; otherwise, print No.

Sample Input 1

4 1 10
5 7 5
2 10

Sample Output 1

Yes
  • Takahashi is initially in Room 11, and the time limit is 1010.
  • He consumes a time of 55 to move to Room 22. Now the time limit is 55. Then, the time limit increases by 1010; it is now 1515.
  • He consumes a time of 77 to move to Room 33. Now the time limit is 88.
  • He consumes a time of 55 to move to Room 44. Now the time limit is 33.

Sample Input 2

4 1 10
10 7 5
2 10

Sample Output 2

No

He cannot move from Room 11 to Room 22.

update @ 2024/3/10 11:11:35