#C4452. Optimal Filterstone Placement

    ID: 47992 Type: Default 1000ms 256MiB

Optimal Filterstone Placement

Optimal Filterstone Placement

In this problem, you are given a water flow system divided into ( n ) segments. Each segment ( i ) is characterized by its flow rate ( f_i ) and its length ( l_i ). A magical constant ( k ) is provided, and the effectiveness of placing a filterstone in segment ( i ) is defined as ( e_i = \frac{k}{f_i \times l_i} ). Your task is to select the segment where the filterstone attains the maximum effectiveness. In case of a tie, choose the segment with the smallest index (i.e., the one that appears first in the input).

Note: Since ( k ) is a positive constant, maximizing ( e_i ) is equivalent to minimizing ( f_i \times l_i ).

inputFormat

The input is read from standard input and consists of four lines:

  1. The first line contains an integer ( n ), the number of segments.
  2. The second line contains ( n ) space-separated integers ( f_1, f_2, \dots, f_n ) representing the flow rates of each segment.
  3. The third line contains ( n ) space-separated integers ( l_1, l_2, \dots, l_n ) representing the lengths of each segment.
  4. The fourth line contains an integer ( k ), the magical constant.

outputFormat

Output a single integer: the 1-based index of the segment with the maximum effectiveness. The output should be written to standard output.## sample

3
10 5 10
2 2 1
100
2

</p>