#K33632. Maximum Packages Transported

    ID: 25131 Type: Default 1000ms 256MiB

Maximum Packages Transported

Maximum Packages Transported

In a warehouse, there are several sections connected by conveyor belts. Each section has a maximum capacity for holding packages, and each conveyor belt between consecutive sections transports packages at a certain speed. In one hour, the number of packages that can be transported from the first section to the last is governed by the smallest throughput along the route. Mathematically, if there are ( n ) sections with capacities ( c_0, c_1, \dots, c_{n-1} ) and conveyor belt speeds ( s_0, s_1, \dots, s_{n-2} ), then the maximum number of packages that can be transported is given by:

[ \text{answer} = \min{c_0, s_0, c_1, s_1, \dots, s_{n-2}, c_{n-1}} ]

You are given the number of sections ( n ), a list of capacities for each section, and a list of speeds for each conveyor belt. Your task is to determine the maximum number of packages that can be transferred from the first section to the last section in one hour.

inputFormat

The input is read from standard input (stdin) and consists of three lines:

  • The first line contains a single integer ( n ) (( n \geq 2 )), representing the number of sections in the warehouse.
  • The second line contains ( n ) space-separated integers representing the capacities of the sections: ( c_0, c_1, \dots, c_{n-1} ).
  • The third line contains ( n-1 ) space-separated integers representing the speeds of the conveyor belts: ( s_0, s_1, \dots, s_{n-2} ).

outputFormat

Output a single integer to standard output (stdout) representing the maximum number of packages that can be transported from the first to the last section in one hour.## sample

5
10 5 8 7 10
4 4 4 4
4