No.3683 サーバー代がもったいない!
タグ : / 解いたユーザー数 136
作問者 :
ゆにたりー卿
drken1215
lp_ql
yimiya(いみや)
よには
👑
Andrew8128
👑
leaf_1415
triangle_coder
👑 This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
Driven by the strong belief that "allocating server resources to code suspected of using AI is a waste," Iwai Seijin exploited a vulnerability and broke into the judge server of IWAtCoder, a competitive programming web service.
Currently, $N$ submissions are lined up in order in the judge, and the "cheating score" of the $i$-th submission from the front is ${A_i}$. Since some of the code definitely does not use AI, ${A_i}$ may be negative. Iwai Seijin wants to choose and delete exactly $K$ of these submissions, maximizing the total cheating score of the deleted submissions.
However, the server is being monitored by Takahashi-kun, and if both of two consecutive submissions are deleted, Takahashi-kun will discover the intrusion into the server, and Iwai Seijin's IWAtCoder account will be banned.
Find the maximum possible total cheating score of the deleted submissions when exactly $K$ submissions are deleted without Takahashi-kun finding out.
Input
$N\ K$ $A_1\ A_2\ \dots A_N$
Constraints
- $1 \le N \le 10^5$
- $1 \le K \le 50$
- $-10^9 \le A_i \le 10^9$
- All input values are integers.
Output
Print the maximum total cheating score when $K$ submissions are deleted so as to satisfy the condition. If it is impossible, print Impossible.
Sample
Sample 1
Input
5 2 10 20 30 40 50
Output
80
Deleting the ${3}$-rd submission (cheating score $30$) and the ${5}$-th submission (cheating score $50$) gives a total of $80$.
Sample 2
Input
4 3 -10 -20 100 100
Output
Impossible
Iwai Seijin's IWAtCoder account will inevitably be banned.
Sample 3
Input
4 2 -10 -20 100 100
Output
90
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。