1770:跑步

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:5 解决: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">分;
  • 如果在一段路上选择突击,分数会加倍,变成 lns="http://www.w3.org/1998/Math/MathML">2 分,但下一段路就只能慢走了;
  • 如果在一段路慢走,得分为 lns="http://www.w3.org/1998/Math/MathML">0

小爱在每段路上应该如何选择,才能使得分之和最大呢?

输入

第一行:单个整数 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">


  • 对于 lns="http://www.w3.org/1998/Math/MathML">30% 的数据,lns="http://www.w3.org/1998/Math/MathML">1100
  • 对于 lns="http://www.w3.org/1998/Math/MathML">60% 的数据,lns="http://www.w3.org/1998/Math/MathML">11000
  • 对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1100000
    lns="http://www.w3.org/1998/Math/MathML">110000


输出

单个整数:表示答案。

样例输入-1 复制

4
1 2 3 4

样例输出-1 复制

14