## ECOO '15 R1 P1 - When You Eat Your Smarties

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type

When I eat my Smarties I always eat the red ones last. I separate them into their color groups and I start by eating the orange ones, then blue, green, yellow, pink, violet, brown and finally red. The red ones are the best, so I eat them slowly one at a time. The other colors I eat quickly by the handful (my hand can hold a maximum of Smarties). I always finish all the Smarties of one color before I move on to the next, so sometimes the last handful of a color isn't a full one.

But wait, there's more! I have turned my Smartie-eating into a science. I know it always takes me exactly seconds to eat a handful of non-red Smarties and I adjust my chewing rate so that I always take seconds even if my hand is not completely full. When I eat the red Smarties I like to take my time, so it takes me exactly seconds to eat each one. I have a big box of Smarties. After I've finished sorting the colors, how long will it take me to eat them?

The input will contain test cases. Each test case will start with lines , where each line holds the color of a single Smartie in lower case. Then the last line will read end of box meaning there are no more Smarties in the box for that test case.

Your program should output a single line for each test case indicating how long (in seconds) it will take me to eat the entire box according to the rules given above. Note that the sample input below only contains test case, but the real data files will contain .

#### Sample Input

red
brown
brown
violet
blue
pink
blue
blue
pink
brown
yellow
brown
pink
violet
green
yellow
red
orange
orange
blue
brown
pink
red
red
red
brown
orange
orange
green
red
orange
violet
blue
pink
yellow
pink
brown
orange
green
red
blue
yellow
green
orange
brown
orange
pink
violet
brown
red
end of box

#### Sample Output

245

Note: Only case is shown in this sample.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org

• commented on Sept. 11, 2021, 9:55 a.m.

Should I take the input for one box, give the output and go on to the next or should I take the input for all boxes and give the output for them at the end? Is there even a difference?

Just commenting (not asking for help with my code!): I don't know what is going on here. I´m overstrained. The "execution results" are not helpful.

• commented on Sept. 2, 2021, 9:32 p.m. edited

I almost got it 4.5/5, can someone tell me where I am wrong?

• commented on Aug. 2, 2021, 5:46 p.m.

Caution, pay extra attention to the 'The input will contain 10 test cases.'

This test goes against the typical convention i've see on here, and expects you to process all 10 test cases in the same execution. If you are only getting the first test case right, and all others wrong, you likely made the same mistake/assumption that I did and only processed the first test case.

• commented on Oct. 16, 2015, 11:10 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Oct. 18, 2015, 4:28 p.m.

Do not prompt for input.

• commented on April 5, 2015, 5:03 p.m.

When I count and calculate the sample, it gives me 258. Is there something really obvious that I'm missing?

• commented on April 5, 2015, 5:46 p.m.

"I always take 13 seconds even if my hand is not completely full."