atcoder#ABC265B. [ABC265B] Explore

[ABC265B] Explore

Score : 200200 points

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.

4 1 10
5 7 5
2 10
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.
4 1 10
10 7 5
2 10
No

He cannot move from Room 11 to Room 22.