Candies
InterviewTime limit1sMemory limit1024 MB
Given n counts and a bonus of up to y for bobo 1, find the most candies bobo 1 can hold after m rounds, where each round the minimum (ties to the smallest label) gets x.
- Level
Medium5 of 10
- Topics
- Heap, Simulation, Greedy
- Solved
- No attempts yet
Problem
bobo are playing a game about candies. The bobo are labeled for convenience. Initially, the -th bobo holds candies.
The game is played in rounds. In each round, the bobo with the fewest candies is awarded candies. If two or more bobo have the same number of candies, the bobo with the smallest label gets the prize.
The 1st bobo is their leader. Before the game starts, he can receive up to more candies from some unknown source. Find the maximum number of candies he can have after the rounds.
Input
The first line contains four integers , , , (, ).
The second line contains integers ().
Output
Print a single integer: the maximum number of candies the 1st bobo can have after the rounds.