Starting from:

$25

Morning Problem: Planning Practice

CMPUT 275 - Tangible Computing
Morning Problem: Planning Practice
Description
You love playing music, especially drums! But your neighbours keep complaining that you’re
too noisy and it sounds terrible. They don’t want to listen to you play until you’ve spent
at least t hours mastering your instrument, maybe then you’ll sound good. You want to
practice enough for them to listen. The only issue is, you can only practice when none of
them are around, otherwise they’ll get upset.
Thankfully it seems nobody changes their schedule day to day, they all leave and get home
at the same time as they did the day before. You’ve been keeping an eye out for when each
of your neighbours leaves and comes home, all that’s left to do is find out when no one is home.
Input
The first line of input will contain two space separated integers n, (1 ≤ n ≤ 50), the amount
of neighbours you have, and t, (1 ≤ t ≤ 100, 000) the amount of time required to master
your instrument.
n lines follow, each will contain two space separated integers, si
, (0 ≤ s ≤ 23), the time
neighbour i left their home, and ei
, (0 ≤ e ≤ 23), the time neighbour i returned home. Note,
the time between si and ei will never exceed 23 hours.
Output
The only line of output will contain a single integer, the amount of days it took to master
your instrument. If your neighbours are always home then print “IMPOSSIBLE”, sadly you
won’t be able to master your instrument.
Sample Input 1
1 10
9 17
Sample Output 1
2
Explanation:
You have a single neighbour and they are gone from 9:00 to 17:00, this is an 8 hour block that
you can practice, it will take 2 days of practising 8 hours a day to master your instrument
with 10 hours of practice.
Sample Input 2
2 60
20 10
10 20
Sample Output 2
IMPOSSIBLE
Explanation:
Your neighbours are on alternate schedules, one is gone during the day and one is gone
during the night, this means that one of them is always home, so you cannot master your
instrument.

More products