P4399 [JSOI2008] Blue Mary's Staff Allocation

Description

Thanks to Blue Mary’s dedicated management, Blue Mary’s Internet company is thriving. It currently has $n$ employees, but no money or reputation. On average, each employee can bring the company $x$ units of money or $y$ units of reputation per day (they cannot produce both at the same time). You can spend $z$ units of money to post a recruitment advertisement on the talent market; exactly three days after posting, one employee will be hired. Moreover, you may post the next advertisement only on the day when the hired employee arrives (i.e., exactly three days after a previous ad). Blue Mary plans to obtain at least $A$ units of money and at least $B$ units of reputation in the shortest possible time. Please compute the minimum time she needs to reach this goal.

Input Format

The input contains exactly one line with six integers $n, x, y, z, A$ and $B$, as described above.

Output Format

Output one line with a single integer, the minimum time Blue Mary needs to achieve the goal.

Explanation/Hint

Constraints: $1 \le n, x, y, z, A, B \le 20$. Translated by ChatGPT 5