QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 10

#10643. Tanie linie [A]

統計

Bajtazar 即将开始期待已久的假期,他打算在比托克海的金色沙滩上享受阳光。考虑到自己的生物节律、天气预报以及比托齐亚的文化和教育活动安排,Bajtazar 为假期中的每一天都指定了一个 休闲系数,表示当天他玩得有多开心。每个系数都是一个整数,也可能是负数——这意味着 Bajtazar 更愿意呆在家里修剪花园。

幸运的是,Bajtazar 并不需要整个假期都待在海边。他最喜欢的廉价航空公司推出了促销活动,使得 Bajtazar 能以极具吸引力的价格购买至多 $k$ 张机票(每张机票都包含前往比托克海及返程的往返行程)。

请帮助 Bajtazar 安排假期,使他在海边度过的那些天的休闲系数之和最大,前提是整个假期他最多只能飞到海边 $k$ 次。为简化问题,假设飞机在夜间运行。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$($1 \le k \le n \le 1,000,000$)。第二行包含 $n$ 个整数(绝对值不超过 $10^9$),依次表示 Bajtazar 假期每一天的休闲系数。

输出格式

输出仅一行,包含一个整数,表示最优假期安排下的休闲系数之和。

示例

输入

5 2
7 -3 4 -9 5

输出

13
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.