結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-09-05 13:04:40 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 2,000 ms |
| + 880µs | |
| コード長 | 436 bytes |
| 記録 | |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 95,956 KB |
| 実行使用メモリ | 99,172 KB |
| 最終ジャッジ日時 | 2026-09-05 13:05:20 |
| 合計ジャッジ時間 | 5,424 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
inf = 1<<60
dp0 = [-inf] * (k+1)
dp1 = [-inf] * (k+1)
dp0[0] = 0
for a in A:
ndp0 = [-inf] * (k+1)
ndp1 = [-inf] * (k+1)
for i in range(k):
ndp1[i+1] = dp0[i]+a
for i in range(k+1):
ndp0[i] = max(dp0[i], dp1[i])
dp0, dp1 = ndp0, ndp1
ans = max(ndp0[k], ndp1[k])
if ans < -(1<<50):
print("Impossible")
else:
print(ans)
kidodesu