MWC '15 #1 P1: Playlist Panic

View as PDF

Submit solution


Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

aurpine likes to listen to various songs in his music playlist, especially by Young Thug. Specifically, his playlist contains N (1 \le N \le 1000) songs. However, being extremely busy, he does not have a lot of time to listen to music.

Each song takes a certain amount of time to listen to, specifically M_i (0 \le M_i \le 100) minutes and S_i (0 \le S_i \le 100) seconds.

If aurpine has X (0 \le X \le 100) minutes and Y (0 \le Y \le 100) seconds to listen to music today, what is the maximum number of songs he can listen to?

Input Specification

The first line contains one integer, N, specifying the number of songs in the playlist.

The next N lines each have two space separated integers, M_i and S_i, specifying the time it takes to listen to the i^{th} song in minutes and seconds.

The last line of input contains two space separated integers, X and Y, representing the time that aurpine has to listen to his playlist. X represents the amount of time in minutes and Y represents the time in seconds.

Output Specification

The output should consist of one integer representing the maximum number of songs that can be listened to.

Sample Input

5
1 30
2 45
4 90
0 10
14 2
9 44

Sample Output

3

Explanation for Sample Output

The 1st, 2nd and 4th songs can be played in the given time.


Comments


  • -2
    gavin_chen  commented on Oct. 17, 2022, 12:04 a.m.

    may anyone check my code i am unsure why i am getting a ValueError rn, if you can thx!


  • 3
    omaewamoushindeiru  commented on July 17, 2022, 1:13 p.m. edit 2

    free(Young Thug);


  • 2
    jman579  commented on Nov. 30, 2020, 4:22 p.m.

    Congrats to the person who did the question in Assembly x64


  • 2
    m4m3sh1b4  commented on Nov. 2, 2017, 9:47 p.m.

    If X and Y is bigger than the sum of all the numbers does the playlist loop back around?


  • 10
    CursedBlackCat  commented on March 16, 2016, 12:27 a.m.

    Who has a song that's 10 seconds long?