#P4399. [JSOI2008] Blue Mary的职员分配

[JSOI2008] Blue Mary的职员分配

Description

Thanks to Blue Mary’s dedicated management, Blue Mary’s Internet company is thriving. It currently has nn employees, but no money or reputation. On average, each employee can bring the company xx units of money or yy units of reputation per day (they cannot produce both at the same time). You can spend zz 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 AA units of money and at least BB 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,An, x, y, z, A and BB, as described above.

Output Format

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

1 2 3 4 5 6
5

Hint

Constraints: 1n,x,y,z,A,B201 \le n, x, y, z, A, B \le 20.

Translated by ChatGPT 5