Candies
시간 제한1초메모리 제한1024 MB
보보 1은 게임 전에 최대 y개의 사탕을 미리 가질 수 있고, 매 라운드 최솟값을 가진 보보가 x개를 받을 때 보보 1의 최종 사탕 수의 최댓값을 구한다.
문제
bobo are playing a game about candies. bobo are labeled by for convenience. Initially, the -th bobo has candies in hand.
The game is played in rounds. In each round, the bobo who has the least number of candies currently is awarded with candies. If two or more bobo have the same number of candies, the bobo with the smallest label gets the prize.
The -st bobo is their leader. So he can get at most more candies from some unknown source before the start of the game. Now he wonder the maximum number of candies he can have after the rounds.
입력
The first line contains integers ().
The second line contains integers ().
출력
A single integer denotes the maximum number of candies.