US Mission - Space cloister

Title Description

There is a space called the cloister of the game, the game has n rooms are connected in sequence, as shown, can come to room No. 1 No. 2 the room, and so on, n number of rooms can go No. 1 room.

The ultimate goal of this game is to leave as much as possible in these rooms mark, leaving the mark of mana spent in each room is different, he is known there are m mana, these are not magic recovery.

Xiao Ming new to the game, so the only upright play, so his every action is to be expected:

1. Start a Xiaoming located in a room.

2. If the rest of his magic can leave a mark in the current room, then he will not hesitate to spend mana.

3. Whether or not left a mark, at the next moment he would enter a room if the room is currently located i, i + 1 will enter the room if the room number will be entered in n No. 1 room.

4. When repeated after a certain room, you can leave a mark again.

Obviously, this game will be terminated, that the remaining mana can not leave the room at any time mark, the game ends. Will he be able to leave a mark total of how many.

 

Input Requirements

Input of the first line has two positive integers n and m, represent the number of rooms mana and Bob have. (1 <= n <= 100000,1 <= m <= 10 ^ 18)

The second input line has n positive integer of 1 to No. n mana cost representing the imprint left room. (1 <= a_i <= 10 ^ 9)

 

Output requirements

Output contains only one integer, that is left up to the mark.
 

If the input

 4 21 2 1 4 3

 

It should be output

9

prompt

Sample explained:
All rooms are apparently leaving two mark, then the remaining point of mana, and then only to leave a mark in the 2nd room.

Guess you like

Origin www.cnblogs.com/lwp-nicol/p/12622615.html