結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 13:58:59 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 174 ms / 2,000 ms |
| + 822µs | |
| コード長 | 731 bytes |
| 記録 | |
| コンパイル時間 | 228 ms |
| コンパイル使用メモリ | 95,816 KB |
| 実行使用メモリ | 101,632 KB |
| 最終ジャッジ日時 | 2026-09-05 13:59:51 |
| 合計ジャッジ時間 | 7,147 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
import itertools
from copy import deepcopy
from functools import cache
import sys
sys.setrecursionlimit(10 ** 9)
import math
from collections import Counter, deque
input = lambda: sys.stdin.readline().rstrip()
mod = 998244353
n, k = map(int, input().split())
a = list(map(int, input().split()))
now_dp = [[-math.inf, -math.inf] for _ in range(k + 1)]
now_dp[0][1] = 0
# print(dp)
for i in range(n):
for j in range(k, 0, -1):
if now_dp[j][0] != -math.inf:
now_dp[j][1] = max(now_dp[j][1], now_dp[j][0])
if now_dp[j - 1][1] != -math.inf:
now_dp[j][0] = now_dp[j - 1][1] + a[i]
# print(next_dp)
if max(now_dp[-1]) == -math.inf:
print("Impossible")
else:
print(max(now_dp[-1]))