Connection Status:
Competition Arena > Insomnia
SRM 106 · 2002-07-29 · by axchma
Class Name: Insomnia
Return Type: int
Method Name: sheepCount
Arg Types: (int)
Problem Statement

Problem Statement

When I can't sleep I count sheep. During the first hour I count 900 sheep (I start at 1 and count up: 1, 2, 3, ..., 899, 900). During the next hour I count them down (so as to avoid having my numbers of sheep grow too large), that is, I count 899, 898 etc. As I count down slower than up, I count 600 sheep down during the second hour. Then I count up again, and so forth.

Your task is, given the number of minutes I spend trying to get to sleep, return the final number of sheep where I stop counting.

Notes

  • Assume that each hour I count evenly: either 15 sheep a minute up, or 10 sheep a minute down.

Constraints

  • minutes is between 0 and 720, inclusive.
Examples
0)
0
Returns: 0
1)
120
Returns: 300
2)
2
Returns: 30
3)
185
Returns: 1150
4)
1
Returns: 15

Submissions are judged against all 26 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class Insomnia with a public method int sheepCount(int minutes) · 26 test cases · 2 s / 256 MB per case

Submitting as anonymous