The Best Rifle
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk is a very good sniper. Unfortunately, his sniper rifle is already broken, so it’s time to buy a new one. Zenyk is considering three rifle options for purchase:
the first rifle deals \(a_1\) damage per shot and is capable of shooting every \(b_1\) minutes,
the second rifle deals \(a_2\) damage per shot and is capable of shooting every \(b_2\) minutes,
the third rifle deals \(a_3\) damage per shot and is capable of shooting every \(b_3\) minutes.
Zenyk always follows the same scenario when hunting occupiers. He finds a spot from which he will shoot, and then shoots for \(x\) minutes, as often as his rifle allows him. He wants to be as efficient a sniper as possible, so he needs the rifle with which he can deal the most damage in \(x\) minutes. Help Zenyk and tell him which rifle he should buy. Note that Zenyk shoots at the 0-th minute, and he can also shoot at the \(x\)-th minute and then leave the position.
Input
The first line contains 7 integers \(a_1, b_1, a_2, b_2, a_3, b_3, x\) — the characteristics of the rifles and the number of minutes during which Zenyk will shoot.
Output
In a single line, print a single integer — the number of the rifle that is best for Zenyk to buy.
If there are several rifles that are equally effective, print the smallest number among such rifles.
Constraints
\(1 \le a_i \le 10^5\),
\(1 \le b_i, x \le 10^4\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 2 4 3 3 1 9 | 3 |
Notes
With the first rifle, Zenyk will be able to make shots at \(0, 2, 4, 6, 8\), each dealing \(3\) damage, and in total Zenyk will deal \(15\) damage.
With the second rifle, Zenyk will be able to make shots at \(0, 3, 6, 9\), each dealing \(4\) damage, and in total Zenyk will deal \(16\) damage.
With the third rifle, Zenyk will be able to make shots at \(0, 1, 2, 3, 4, 5, 6, 7, 8, 9\), each dealing \(3\) damage, and in total Zenyk will deal \(30\) damage.
Thus, it is best to choose the third rifle.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|