問題一覧 > 通常問題

No.3683 サーバー代がもったいない!

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 136
作問者 : edon8618 / テスター : ゆにたりー卿 drken1215 Mikan04y lp_ql yimiya(いみや) よには 👑 loop0919 elphe Andrew8128 👑 seekworser leaf_1415 紫前燈太 triangle_coder 👑 みうね
お気に入りにしたユーザー ProblemId : 13531 / 自分の提出
問題文最終更新日: 2026-09-05 01:34:07
What a Waste of Server Costs!
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
第3回 岩井星人アンソロジープログラミングコンテスト (順位表) の他の問題:

Definitely AI!

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もしくは右上の雲マークをクリックしてアカウントを作成してください。