/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 333 点
問題文
高橋君はプログラミングの勉強を始めました。彼が使っている学習サイトには N 個の練習問題があり、それぞれの問題には難易度が設定されています。i 番目の問題の難易度は D_i です。
高橋君の現在のスキルレベルは S です。高橋君が問題を解くと、その問題の難易度の分だけスキルレベルが上昇します。ただし、高橋君は現在のスキルレベル以下の難易度の問題しか解くことができません。
高橋君は、目標スキルレベル T に到達することを目指しています。
高橋君は各問題を最大 1 回ずつ解くことができます。高橋君が適切に問題を選んで解いたとき、最終的なスキルレベルを目標スキルレベル T 以上にすることができるかどうかを判定してください。
できる場合は Yes を、できない場合は No を出力してください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq S \leq T \leq 10^{18}
- 1 \leq D_i \leq 10^{9}
- 入力はすべて整数
入力
N S T D_1 D_2 \ldots D_N
- 1 行目には、問題の個数を表す N 、高橋君の初期スキルレベルを表す S 、目標スキルレベルを表す T が、スペース区切りで与えられる。
- 2 行目には、各問題の難易度を表す D_1, D_2, \ldots, D_N が、スペース区切りで与えられる。
出力
高橋君の最終的なスキルレベルを T 以上にできる場合は Yes を、できない場合は No を 1 行で出力せよ。
入力例 1
5 3 20 2 3 5 8 1
出力例 1
Yes
入力例 2
3 1 100 5 10 20
出力例 2
No
入力例 3
10 5 50 3 7 2 8 4 15 6 1 12 9
出力例 3
Yes
入力例 4
15 10 1000000000000000000 999999999 1000000000 500000000 800000000 200000000 100000000 50000000 10 5 3 2 1 7 8 4
出力例 4
No
入力例 5
1 1 1 1
出力例 5
Yes
Score : 333 pts
Problem Statement
Takahashi has started studying programming. The learning site he uses has N practice problems, each with an assigned difficulty level. The difficulty of the i-th problem is D_i.
Takahashi's current skill level is S. When Takahashi solves a problem, his skill level increases by the difficulty of that problem. However, Takahashi can only solve problems whose difficulty is less than or equal to his current skill level.
Takahashi aims to reach a target skill level of T.
Takahashi can solve each problem at most once. Determine whether Takahashi can reach a final skill level of at least T by choosing and solving problems appropriately.
If he can, output Yes; otherwise, output No.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq S \leq T \leq 10^{18}
- 1 \leq D_i \leq 10^{9}
- All inputs are integers.
Input
N S T D_1 D_2 \ldots D_N
- The first line contains N, the number of problems, S, Takahashi's initial skill level, and T, the target skill level, separated by spaces.
- The second line contains the difficulties of each problem, D_1, D_2, \ldots, D_N, separated by spaces.
Output
If Takahashi's final skill level can be made at least T, output Yes; otherwise, output No on a single line.
Sample Input 1
5 3 20 2 3 5 8 1
Sample Output 1
Yes
Sample Input 2
3 1 100 5 10 20
Sample Output 2
No
Sample Input 3
10 5 50 3 7 2 8 4 15 6 1 12 9
Sample Output 3
Yes
Sample Input 4
15 10 1000000000000000000 999999999 1000000000 500000000 800000000 200000000 100000000 50000000 10 5 3 2 1 7 8 4
Sample Output 4
No
Sample Input 5
1 1 1 1
Sample Output 5
Yes