Playlist
InterviewTime limit2sMemory limit1024 MB
Decide whether the first song can be playing at second T when the shuffle plays every song once per round in random order.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Implementation
- Solved
- No attempts yet
Statement
Vasya likes to listen to music from his favorite playlist while doing homework. The playlist has songs, and each song lasts an integer number of seconds.
Vasya used to listen to the songs in the same order, but he got bored quickly because he knew which song would come next. Luckily, his player has a shuffle feature. It changes the playback order randomly, but a song cannot start playing again until the whole playlist has been played. Now Vasya always listens with shuffle turned on.
Once, Vasya started the music to do homework, but he was distracted and returned only after seconds. He wonders whether his favorite song could be playing at that moment, and asked you for help.
A song is considered playing at time if it plays for at least the next second.
Input
The first line contains two integers and (, ): the number of songs in the playlist and the number of seconds after which Vasya returned.
The second line contains integers (), the durations of the songs in seconds. The first song is Vasya's favorite.
Output
Print Yes if Vasya's favorite song can be playing at time , and No otherwise.