P4851 yyf hates ganhuodong

Background

The unlucky guy (feiqiu) yyf knows he is too unlucky, so he starts grinding the event. yyf finally becomes a hardcore grinder (gandi), but he still wants to save as much $\mathrm{loveca}$ as possible. Otherwise, if he spends too much $\mathrm{loveca}$, yyf will feel very bad about it.

Description

You are given the following $11$ positive integers: $a$: the event $\mathrm{pt}$ gained by completing one song. $b$: the $\mathrm{LP}$ required to complete one song. $c$: the initial $\mathrm{LP}$ cap when you start grinding the event. $d$: the initial $\mathrm{LP}$ when you start grinding the event. $e$: the initial experience cap when you start grinding the event. $f$: the initial experience when you start grinding the event. $g$: the experience gained from playing one song. $h$: the increase in the $\mathrm{LP}$ cap when leveling up by one level. $k$: the increase in the experience cap when leveling up by one level. $x$: the remaining time until the event ends (in hours). $y$: your target event $\mathrm{pt}$. Assume yyf can play songs without spending time. Each time you play a song, you need to spend some $\mathrm{LP}$ to gain some event $\mathrm{pt}$ and some experience. yyf starts with event $\mathrm{pt}$ equal to $0$. $\mathrm{LP}$ automatically recovers $1$ point per hour. When $\mathrm{LP}$ reaches the cap, it will not recover automatically (you do not need to consider this situation in this problem), but it can exceed the cap using the method described later. When experience reaches the cap, you level up. When leveling up, your $\mathrm{LP}$ cap increases and you recover “the new $\mathrm{LP}$ cap” (after the increase) points of $\mathrm{LP}$. The recovered $\mathrm{LP}$ can exceed the $\mathrm{LP}$ cap. Any overflow experience is carried over to the next level-up, and the required experience for the next level-up (the experience cap) will increase. You can spend one $\mathrm{loveca}$ at any time to gain $\mathrm{LP}$ equal to your current $\mathrm{LP}$ cap (this can exceed the cap). Your goal is to obtain event $\mathrm{pt}$ greater than or equal to $y$. Find the minimum number of $\mathrm{loveca}$ you need to spend. Formally, your initial $\mathrm{LP}$ can be considered as $d+x$. You have two operations: 1. Let the experience before the operation be $\mathrm{exp}$, the $\mathrm{LP}$ cap be $\mathrm{LPmax}$, the current $\mathrm{LP}$ be $l$ (you can perform operation $1$ if and only if $l \ge b$), and the experience cap be $\mathrm{EXPmax}$. After this operation, event $\mathrm{pt}$ increases by $a$. - If $\mathrm{exp+g \ge EXPmax}$, then the remaining $\mathrm{LP}$ becomes $l-b+\mathrm{LPmax}+h$, the experience becomes $\mathrm{(exp+g)\bmod EXPmax}$, the $\mathrm{LP}$ cap increases by $h$, and the experience cap increases by $k$. - Otherwise, the remaining $\mathrm{LP}$ becomes $l-b$, and the experience becomes $\mathrm{exp+g}$. 2. Let the $\mathrm{LP}$ cap before the operation be $\mathrm{LPmax}$ and the current $\mathrm{LP}$ be $l$. After this operation, the remaining $\mathrm{LP}$ becomes $\mathrm{LPmax}+l$. Your goal is to make your event $\mathrm{pt}$ greater than or equal to $y$. Find the minimum number of times you need to perform operation $2$. Since playing songs does not take time, you can play any number of songs at the exact moment the event ends, i.e. you can perform operation $1$ any number of times. Therefore, the initial $\mathrm{LP}$ can be considered as $d+x$.

Input Format

A single line containing the above $11$ positive integers, with meanings as described above.

Output Format

A single positive integer, representing the minimum number of $\mathrm{loveca}$ that must be spent.

Explanation/Hint

$a∈[1,10]$ $b∈[5,20]$ $c∈[30,50]$ $d∈[5,10]$ $e∈[100,200]$ $f∈[1,50]$ $g∈[10,20]$ $h∈[5,10]$ $k∈[10,20]$ $x∈[10,15]$ $y∈[5000,10000]$ Translated by ChatGPT 5