Given a start temperature below target, compute total heating time using per-degree rates for frozen and unfrozen states plus a fixed thawing time.
Easy2MathImplementationSimulationInterviewNo attempts yetTime limit2sMemory limit512 MBTo prepare a meal, JOI wants to heat a piece of meat from A°C to B°C in a microwave. The meat is frozen when its temperature is below 0°C and not frozen when it is above 0°C. When the temperature is exactly 0°C, the meat may be either frozen or not frozen.
JOI assumes that the meat heats up according to the rules below and uses them to estimate how long the heating takes.
Using these rules, find how many seconds it takes to heat the meat to B°C.
The input has five lines, each containing one integer.
C, D, and E are each between 1 and 100 inclusive.
Print on one line the time in seconds needed to heat the meat to B°C.
In sample 1, the meat starts frozen at −10°C. The time is made up as follows.
The total is 120 seconds.
In sample 2, the meat is not frozen at the start, so heating it from 35°C to 92°C takes 627 seconds.