1685:股票市场

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:7 解决:2

题目描述

小爱知道一只股票在今后 lns="http://www.w3.org/1998/Math/MathML"> 天的价格。在第一天开始前,小爱有 lns="http://www.w3.org/1998/Math/MathML"> 元,那么在最后一天结束后,她最多能有多少钱呢?小爱每天都可以买入或卖出股票,注意股票在交易时的最小单位为 lns="http://www.w3.org/1998/Math/MathML">1 股。例如当有 lns="http://www.w3.org/1998/Math/MathML">13 元的时候,若股价为 lns="http://www.w3.org/1998/Math/MathML">4 元一股,则最多只能买 lns="http://www.w3.org/1998/Math/MathML">3 股。

规定每天只能交易一次,如果当天已经买入股票,就不能卖出,反之,如果当天已经卖出,则不能再买进股票。

输入

 第一行:两个整数,表示 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML">
第二行:lns="http://www.w3.org/1998/Math/MathML"> 个整数 lns="http://www.w3.org/1998/Math/MathML">1,,,表示每天的股票价格。


  • lns="http://www.w3.org/1998/Math/MathML">1100
  • 对于 lns="http://www.w3.org/1998/Math/MathML">30% 的数据,lns="http://www.w3.org/1998/Math/MathML">120
  • 对于 lns="http://www.w3.org/1998/Math/MathML">60% 的数据,lns="http://www.w3.org/1998/Math/MathML">15,000
  • 对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1100,000
  • 保证输出答案不超过1018


输出

单个整数:表示能获得的最大钱数。

样例输入-1 复制

6 100
1 2 10 1 5 10

样例输出-1 复制

10000