P3926 SAC E#1 - An Impossible Problem Jelly
Background
SOL 君 (Hearthstone streamer) and SOL 菌 (Perfect Information Classroom lecturer) are good friends.
Description
SOL 君 likes eating konjac jelly, and SOL 菌 also likes konjac jelly.
One day, they were playing Hearthstone together, and SOL 菌 was going to serve konjac jelly to his guest.
Konjac jelly is usually stored in a refrigerator at $a$ degrees. However, it is too cold right after being taken out and needs to be heated. SOL 菌 plans to heat the konjac jelly with a magical electric stove. According to observation, it has the following behavior:
1. When the jelly is below $c$ degrees, it heats by $1$ degree every $p$ units of time.
2. When the jelly is exactly $c$ degrees, it needs $q$ units of time to thaw (everyone knows that during a phase change the temperature does not change... SOL 菌 believes jelly is crystalline).
3. After thawing is complete, it heats by $1$ degree every $r$ units of time.
SOL wants to know the temperature of the jelly after heating for $x$ units of time.
The temperature is floored. That is, if the heating ends with less than $p$ (or $q$) units of time, then during this final short period the temperature does not change at all.
Input Format
The input contains a single line with $6$ integers: $a, c, p, q, r, x$.
Output Format
Output a single integer: the required temperature.
Explanation/Hint
For $30\%$ of the testdata, $|a|, |c| \leq 200$, $x \leq 100$.
For $60\%$ of the testdata, $|a|, |c| \leq 2 \times 10^9$, $x \leq 100$.
For $100\%$ of the testdata, $|a|, |c| \leq 2 \times 10^9$, $1 \leq x, p, q, r \leq 10^9$.
The testdata may have $a = c$, which should be considered as the not-yet-thawed state.
Hint: Please use the long long data type.
Translated by ChatGPT 5