WakingUpEasy
SRM 616 · 2013-12-22 · by tourist
Problem Statement
Unfortunately, several alarms are going to disturb him. These alarms will be ringing in a cyclic order. Each alarm is characterized by its volume.
You are given a list of alarm volumes in a
While Alex's sleepiness is positive, he's still sleeping. Once it becomes less than or equal to zero, Alex immediately wakes up.
Return the number of alarms after which Alex will wake up.
Constraints
- volume will contain between 1 and 50 elements, inclusive.
- Each element of volume will be between 1 and 100, inclusive.
- S will be between 1 and 10000, inclusive.
{5, 2, 4}
13
Returns: 4
Initially, Alex's sleepiness is 13, and the list of alarms is {5, 2, 4}. After the first alarm, Alex's sleepiness is 8. The list of alarms becomes {2, 4, 5}. After the second alarm, Alex's sleepiness is 6. The list of alarms becomes {4, 5, 2}. After the third alarm, Alex's sleepiness is 2. The list of alarms becomes {5, 2, 4}. After the fourth alarm, Alex's sleepiness is -3, so Alex wakes up.
{5, 2, 4}
3
Returns: 1
The first alarm is enough here.
{1}
10000
Returns: 10000
The only alarm has to ring 10000 times before Alex finally wakes up.
{42, 68, 35, 1, 70, 25, 79, 59, 63, 65, 6, 46, 82, 28, 62, 92, 96, 43, 28, 37,
92, 5, 3, 54, 93, 83, 22, 17, 19, 96, 48, 27, 72, 39, 70, 13, 68, 100, 36,
95, 4, 12, 23, 34, 74, 65, 42, 12, 54, 69}
9999
Returns: 203
{1}
1
Returns: 1
Submissions are judged against all 66 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class WakingUpEasy with a public method int countAlarms(vector<int> volume, int S) · 66 test cases · 2 s / 256 MB per case