QOJ.ac

QOJ

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

#10643. Cheap lines [A]

Statistics

Bajtazar is going on a long-awaited vacation, which he intends to spend basking on the golden sands of the Bitockie Sea. Taking into account his biorhythm, the weather forecast, and the cultural and educational offerings of Bitocja, Bajtazar has assigned a recreation coefficient to each of the $n$ days of his vacation, representing how much fun he will have on that day. Each coefficient is an integer; it may be negative, which means that on that day, Bajtazar would rather be at home weeding his garden.

Fortunately, Bajtazar does not have to spend his entire vacation by the sea. His favorite budget airline has prepared a promotion, thanks to which Bajtazar can purchase up to $k$ flight tickets at an exceptionally attractive price (each ticket is for a round trip to the Bitockie Sea).

Help Bajtazar plan his vacation so that the sum of the recreation coefficients of the days he spends by the sea is as large as possible, assuming that he can fly to the sea at most $k$ times during his vacation. For simplicity, we assume that planes fly at night.

Input

The first line of input contains two integers $n$ and $k$ ($1 \le k \le n \le 1\,000\,000$). The second line contains $n$ integers (each with an absolute value no greater than $10^{9}$), which describe the recreation coefficients for the consecutive days of Bajtazar's vacation.

Output

The only line of output should contain a single integer, which represents the sum of the recreation coefficients in the optimal vacation plan.

Examples

Input 1

5 2
7 -3 4 -9 5

Output 1

13

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.