#P4851. Minimum Loveca Usage
Minimum Loveca Usage
Minimum Loveca Usage
You are given 11 positive integers:
- \(a\): activity points (pt) earned per song play.
- \(b\): LP cost to play one song.
- \(c\): initial LP maximum.
- \(d\): initial LP.
- \(e\): initial experience (EXP) maximum.
- \(f\): initial EXP.
- \(g\): EXP gained per song play.
- \(h\): increase in LP maximum on level-up.
- \(k\): increase in EXP maximum on level-up.
- \(x\): additional hours remaining for automatic LP recovery (each hour recovers 1 LP, so you may treat the initial available LP as \(d+x\)).
- \(y\): target activity points.
The process is as follows. You start with activity points 0, LP \(= d+x\), LP maximum \(= c\), EXP \(= f\) and EXP maximum \(= e\). There are two operations you can perform at any time (song plays take no time):
- Play a song: This operation can only be performed if your current LP \(l \ge b\). Suppose your current EXP is \(\text{exp}\), LP maximum is \(\text{LPmax}\) and EXP maximum is \(\text{EXPmax}\). Upon playing a song, you gain \(a\) activity points. Then:
- If \(\text{exp}+g \ge \text{EXPmax}\), then a level-up occurs. In this case, your new state is:
- LP becomes \(l - b + \text{LPmax} + h\).
- LP maximum becomes \(\text{LPmax} + h\).
- EXP becomes \((\text{exp}+g) \bmod \text{EXPmax}\).
- EXP maximum becomes \(\text{EXPmax} + k\).
- Otherwise, your state is updated as:
- LP becomes \(l - b\).
- EXP becomes \(\text{exp}+g\).
- If \(\text{exp}+g \ge \text{EXPmax}\), then a level-up occurs. In this case, your new state is:
- Use loveca: At any time, you may choose to spend one loveca. This operation adds \(\text{LPmax}\) points to your current LP (note that this may result in LP exceeding your current LP maximum).
Your goal is to achieve at least \(y\) activity points while minimizing the number of times you use loveca (operation 2). It is guaranteed that you can perform an arbitrary number of song plays (operation 1) at any moment.
Calculate the minimum number of loveca required.
inputFormat
The input consists of a single line containing 11 space-separated positive integers:
\(a\) \(b\) \(c\) \(d\) \(e\) \(f\) \(g\) \(h\) \(k\) \(x\) \(y\)
outputFormat
Output a single integer: the minimum number of loveca (operation 2) required to achieve at least \(y\) activity points.
sample
10 5 20 15 10 5 6 3 2 2 30
0