#701
Unrated
Watering the Plants
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie's garden has NN plants labeled 11 through NN (2N51052\leq N\leq 5\cdot 10^5) from left to right. Bessie knows that plant ii requires at least wiw_i (0wi1060\leq w_i \leq 10^6) units of water.

Bessie has a very peculiar irrigation system with N1N-1 canals, numbered 11 through N1N-1. Each canal ii has an associated unit cost cic_i (1ci1061\le c_i\le 10^6), such that Bessie can pay cikc_i k to provide plants ii and i+1i+1 each with kk units of water, where kk is a non-negative integer.

Bessie is busy and may not have time to use all the canals. For each 2iN2\leq i \leq N compute the minimum cost required to water plants 11 through ii using only the first i1i-1 canals.

입력

The first line contains a single positive integer NN.

The second line contains NN space-separated integers w1,,wNw_1, \ldots, w_N.

The third line contains N1N-1 space-separated integers c1,,cN1c_1, \ldots, c_{N-1}.

출력

Output N1N-1 newline-separated integers. The (i1)(i-1)th integer should contain the minimum cost to water the first ii plants using the first i1i-1 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: N200N \leq 200, and all wi200w_i \leq 200.Inputs 5-6: All wi200w_i \leq 200.Inputs 7-10: N5000N \leq 5000.Inputs 11-14: All wiw_i and cic_i are generated independently and uniformly at random.Inputs 15-19: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.