Mushroom Monster (Small)
InterviewTime limit5sMemory limit512 MB
Given plate counts at 10-second intervals, compute the minimum eaten under free eating and under a constant eating rate.
- Level
Easy3 of 10
- Topics
- Simulation, Greedy
- Solved
- No attempts yet
Problem
Kaylin loves mushrooms. Put them on her plate and she eats every one. In this problem she is working through a plate of mushrooms while Bartholomew keeps adding more pieces to it.
We look at the number of mushroom pieces on the plate at 10-second intervals. Bartholomew can put any non-negative integer number of pieces down at any moment, and the only way a piece leaves the plate is by being eaten.
Find the minimum number of pieces Kaylin could have eaten under each of two different methods of computation.
- Assume Kaylin can eat any number of pieces at any time.
- Assume that, starting with the first time we look at the plate, Kaylin eats at a constant rate whenever there are mushrooms on her plate.
Consider the observations 10, 5, 15, 5.
Under the first method Kaylin ate at least 15 pieces: she eats 5, then 10 more are put on her plate, then she eats another 10. There is no way she ate fewer.
Under the second method Kaylin ate at least 25 pieces. Her rate has to be at least 1 piece per second. She starts with 10 pieces on the plate. In the first 10 seconds she eats 10 pieces and 5 more are put down. Over the next 5 seconds she eats those 5, the plate stays empty for 5 seconds, and then Bartholomew puts 15 more pieces down. She eats 10 pieces in the last 10 seconds.
Input
The first line of the input gives the number of test cases, . test cases follow. Each test case takes two lines. The first line contains a single integer , and the second line contains space-separated integers , the number of mushroom pieces on Kaylin's plate at the start and at each following 10-second interval.
Limits
Output
For each test case, output one line in the format Case #x: y z, where is the test case number starting from 1, is the minimum under the first method of computation, and is the minimum under the second method of computation.