/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 200 点
問題文
高橋君は友人との待ち合わせに遅刻しないよう、準備を進めています。高橋君は出発前にいくつかの準備作業をすべて終わらせる必要があります。
待ち合わせに間に合うためには、遅くとも T 時 0 分には家を出発しなければなりません。
高橋君には N 個の準備作業があり、i 番目の作業を完了するには A_i 分かかります。高橋君は同じ日の S 時 0 分から準備を開始し、N 個の作業をそれぞれちょうど 1 回ずつ、休憩なしで連続して行います。すべての作業にかかる時間の合計は A_1 + A_2 + \cdots + A_N 分です。
すべての準備を終えた時刻が T 時 0 分以前であれば、高橋君は待ち合わせに間に合うように出発できます。
高橋君が T 時 0 分までにすべての準備を終えて出発できるかどうかを判定してください。
制約
- 1 \leq N \leq 100
- 0 \leq S \leq 23
- 0 \leq T \leq 23
- S \leq T
- 1 \leq A_i \leq 60 (1 \leq i \leq N)
- 入力はすべて整数である
入力
N S T A_1 A_2 \ldots A_N
- 1 行目には、準備作業の個数を表す整数 N 、準備開始時刻(時)を表す整数 S 、出発期限の時刻(時)を表す整数 T が、スペース区切りで与えられる。
- 2 行目には、各作業にかかる時間(分)を表す整数 A_1, A_2, \ldots, A_N が、スペース区切りで与えられる。
出力
高橋君が T 時 0 分までにすべての準備を終えて出発できる場合は Yes を、できない場合は No を出力してください。
入力例 1
3 9 10 15 20 10
出力例 1
Yes
入力例 2
5 14 17 45 30 25 40 50
出力例 2
No
入力例 3
10 6 12 30 25 45 15 20 35 40 10 50 60
出力例 3
Yes
Score : 200 pts
Problem Statement
Takahashi is preparing so that he won't be late for a meeting with his friend. Takahashi needs to finish several preparation tasks before leaving.
To make it to the meeting on time, he must leave his house by T o'clock 0 minutes at the latest.
Takahashi has N preparation tasks, and the i-th task takes A_i minutes to complete. Takahashi starts preparing at S o'clock 0 minutes on the same day, and performs each of the N tasks exactly once, consecutively without any breaks. The total time for all tasks is A_1 + A_2 + \cdots + A_N minutes.
If he finishes all preparations at or before T o'clock 0 minutes, Takahashi can leave in time for the meeting.
Determine whether Takahashi can finish all preparations and leave by T o'clock 0 minutes.
Constraints
- 1 \leq N \leq 100
- 0 \leq S \leq 23
- 0 \leq T \leq 23
- S \leq T
- 1 \leq A_i \leq 60 (1 \leq i \leq N)
- All inputs are integers
Input
N S T A_1 A_2 \ldots A_N
- The first line contains three space-separated integers: N, the number of preparation tasks; S, the hour at which preparation starts; and T, the hour of the departure deadline.
- The second line contains space-separated integers A_1, A_2, \ldots, A_N, representing the time (in minutes) each task takes.
Output
If Takahashi can finish all preparations and leave by T o'clock 0 minutes, print Yes; otherwise, print No.
Sample Input 1
3 9 10 15 20 10
Sample Output 1
Yes
Sample Input 2
5 14 17 45 30 25 40 50
Sample Output 2
No
Sample Input 3
10 6 12 30 25 45 15 20 35 40 10 50 60
Sample Output 3
Yes