#K36522. Maximum Resources Collection
Maximum Resources Collection
Maximum Resources Collection
You are given n types of resources. For each resource type i (where i ranges from 1 to n), you are given:
- A collection rate ri (the number of resources collected per unit time).
- A switching time ti (the time needed to switch to that resource type).
You also have a total available time T. If you choose resource type i and T \ge ti, then the time available for collection is \(T - t_i\) and you can collect \((T - t_i) \times r_i\) resources. Otherwise, you collect 0 resources from that type.
Your task is to determine the maximum number of resources you can collect by selecting the optimal resource type.
The formula for resources collected for a resource type i (if \(T \ge t_i\)) is given by:
$$ \text{collected}_i = (T - t_i) \times r_i $$inputFormat
The input is given from stdin in the following format:
n r[0] r[1] ... r[n-1] t[0] t[1] ... t[n-1] T
- n is an integer representing the number of resource types.
- The second line contains n space-separated integers representing the collection rates for each resource type.
- The third line contains n space-separated integers representing the switching times for each resource type.
- The fourth line contains an integer T representing the total available time.
outputFormat
Output a single integer to stdout which is the maximum number of resources that can be collected.
## sample1
10
0
10
100