#P41B. Martian Dollar
Martian Dollar
Martian Dollar
题面翻译
一天小V得到了接下来n天,在篮球星有火星元的交易的信息。
第i天每一火星元的市价(不管是买入还是卖出都一样)是a[i]信用点, 小V有b 信用点。
小V最多可以买一次火星元,也只能卖一次火星元。
根据篮球星法律,对火星元的买卖必须以整数为单位。
试问小V在过了n天后最多能得到多少信用点?
输入格式: 第一行两个数 , 第二行,n个数a[i] ,含义如题 输出格式: 一行一个数,表示答案。
Translated by @Maniac丶坚果
题目描述
One day Vasya got hold of information on the Martian dollar course in bourles for the next days. The buying prices and the selling prices for one dollar on day are the same and are equal to . Vasya has bourles. He can buy a certain number of dollars and then sell it no more than once in days. According to Martian laws, one can buy only an integer number of dollars. Which maximal sum of money in bourles can Vasya get by the end of day ?
输入格式
The first line contains two integers and ( ) — the number of days and the initial number of money in bourles. The next line contains integers ( ) — the prices of Martian dollars.
输出格式
Print the single number — which maximal sum of money in bourles can Vasya get by the end of day .
样例 #1
样例输入 #1
2 4
3 7
样例输出 #1
8
样例 #2
样例输入 #2
4 10
4 3 2 1
样例输出 #2
10
样例 #3
样例输入 #3
4 10
4 2 3 1
样例输出 #3
15