문제
Bessie's garden has plants labeled through () from left to right. Bessie knows that plant requires at least () units of water.
Bessie has a very peculiar irrigation system with canals, numbered through . Each canal has an associated unit cost (), such that Bessie can pay to provide plants and each with units of water, where is a non-negative integer.
Bessie is busy and may not have time to use all the canals. For each compute the minimum cost required to water plants through using only the first canals.
입력
The first line contains a single positive integer .
The second line contains space-separated integers .
The third line contains space-separated integers .
출력
Output newline-separated integers. The th integer should contain the minimum cost to water the first plants using the first canals.
예제 입력 1
3
39 69 33
30 29
예제 출력 1
2070
2127
예제 입력 2
3
33 82 36
19 1
예제 출력 2
1558
676
예제 입력 3
8
35 89 44 1 35 3 62 50
7 86 94 62 63 9 49
예제 출력 3
623
4099
4114
6269
6272
6827
8827
점수
Input 4: , and all .Inputs 5-6: All .Inputs 7-10: .Inputs 11-14: All and are generated independently and uniformly at random.Inputs 15-19: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인