Daniel, an ambitious young programmer, decides to go to a party one afternoon. However, having not partied often, Daniel has a bad tolerance for liqour.
Given that it takes an integer
n minutes for Daniel to metabolize the alcohol in one drink, how many hours after drinking his last of
d drinks can Daniel safely drive himself home? Note: Assume that he does not start metabolizing until he has drank his last drink.
Daniel's friend Matt says that Daniel can metabolize twice as fast is he is doing jumping jacks. If Daniel decides to do jumping jacks for
j minutes, hour many hours does he have to wait before leaving the party?
0 < n <= 120
0 <= d <= 12
0 <= j <= n * d / 2
t, the number of test cases.
j, separated by spaces, in that order, for
t following lines.
Output: The number of hours, to the nearest hour, Daniel must wait before coming home.
45 4 30
35 7 12
Test Case 0: To metabolize 4 drinks at a rate of one drink every 45 minutes, it would take Daniel 3 hours to sober up. Daniel does jumping jacks for 30 minutes, though, which shaves an hour off that time. Thus, it takes Daniel 2.5 hours to sober up. Rounding to the nearest hour, it takes Daniel 3 hours to go home.
Test Case 1: To regularly deal with 7 drinks at 35 min/drink, it would take Daniel 245 minutes. Twelve minutes of jumping jacks shaves off 24 minutes from that. In the end, it would take Daniel 233 minutes in total, or 4 hours, to be ready to drive.
Copyright © oaktree, 2016
I'm eager to see what you guys do! It's an easy one, but it's the first one I've actually made. I'll have my solution up soon.