Connection Status:
Competition Arena > SunShroom
SRM 815 · 2021-10-06 · by misof · Simple Math
Class Name: SunShroom
Return Type: long
Method Name: produceSun
Arg Types: (vector<long long>, long long)
Problem Statement

Problem Statement

A Sun-shroom is a mushroom in the Plants vs. Zombies game. When you plant a Sun-shroom, it starts its life as a small mushroom. After two minutes have passed, the Sun-shroom instantly grows to a full-sized mushroom.

While the Sun-shroom is small, it produces 15 sun every 24 seconds. (A "sun" is a unit of currency in the game.) Once it's fully grown, it produces 25 sun every 24 seconds instead.

The first time a Sun-shroom produces sun is 24 seconds after it was planted. At two minutes into its life the shroom first grows and only then produces sun, so the produced amount is 25 sun.


You are given a long[] plantingTime. Each element of plantingTime is a time in seconds (counting from the beginning of the game) when you planted one mushroom.

You are also given a long queryTime (in the same units).

Calculate and return the total amount of sun produced by your shrooms during the first queryTime seconds of the game.

Notes

  • In the actual game you have to purchase the Sun-shrooms before you plant them. In this problem we do not care about these costs.

Constraints

  • plantingTime will have between 1 and 50 elements, inclusive.
  • Each element of plantingTime will be between 0 and 10^12, inclusive.
  • queryTime will be between 1 and 10^12, inclusive.
Examples
0)
{10}
33
Returns: 0

Ten seconds into the game you planted your only shroom. Then you waited for 23 more seconds, but the shroom hasn't produced any sun yet.

1)
{10}
34
Returns: 15

This time you waited one more second and you were rewarded by the first batch of sun produced by the shroom.

2)
{47}
200
Returns: 110

This shroom had enough time to mature and produce its first two bigger batches of sun.

3)
{47, 47, 47, 47, 47, 47}
200
Returns: 660

The same test case as above, but you have planted six shrooms at the same time.

4)
{10, 100, 20, 200, 30, 300, 40, 400}
123456
Returns: 1027230

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

Coding Area

Language: C++17 · define a public class SunShroom with a public method long long produceSun(vector<long long> plantingTime, long long queryTime) · 49 test cases · 2 s / 256 MB per case

Submitting as anonymous