#648
Bronze II
Candy Cane Feast
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John's cows have quite the sweet tooth, and they especially enjoy eating candy canes! FJ has NN total cows, each with a certain initial height and he wants to feed them MM candy canes, each also of varying height (1N,M21051\le N,M\le 2\cdot 10^5).

FJ plans to feed the candy canes one by one to the cows, in the order they are given in the input. To feed a candy cane to his cows, he will hang the candy cane so that initially the candy cane is just touching the ground. The cows will then line up one by one, in the order given by the input, and go up to the candy cane, each eating up to their height (since they cannot reach any higher). The candy cane stays suspended in place where it is initially set up and is not lowered to the ground, even after cows eat the bottom of the candy cane. It is possible a cow may eat nothing during her turn, if the base of the candy cane is already above that cow's height. After every cow has had their turn, the cows grow in height by how many units of candy cane they ate, and Farmer John hangs the next candy cane and the cows repeat the process again (with cow 1 again being the first to start eating the next candy cane).

입력

The first line contains NN and MM.

The next line contains the initial heights of the NN cows, each in the range [1,109][1,10^9].

The next line contains the heights of the MM candy canes, each in the range [1,109][1,10^9].

출력

The final heights of each of the NN cows on separate lines.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 입력 1

3 2
3 2 5
6 1

예제 출력 1

7
2
7

점수

Inputs 2-10: N,M103N, M \le 10^3Inputs 11-14: No additional constraints.

코드 제출

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

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