結果
| 問題 | No.3683 サーバー代がもったいない! |
| コンテスト | |
| ユーザー |
まぬお
|
| 提出日時 | 2026-09-05 13:23:08 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| + 850µs | |
| コード長 | 892 bytes |
| 記録 | |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 95,956 KB |
| 実行使用メモリ | 101,352 KB |
| 最終ジャッジ日時 | 2026-09-05 13:23:15 |
| 合計ジャッジ時間 | 6,186 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right, insort
from itertools import permutations, combinations, groupby
from heapq import heappop, heappush
import math, sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
def printl(li, sep=" "): print(sep.join(map(str, li)))
def yn(flag): print(Yes if flag else No)
_int = lambda x: int(x)-1
MOD = 998244353 #10**9+7
INF = 1<<60
Yes, No = "Yes", "No"
N, K = map(int, input().split())
A = list(map(int, input().split()))
if (N+1)//2 < K:
print("Impossible")
exit()
dp = [-INF]*(K+1)*2
def ind(i, t): return i*2+t
dp[ind(0, 0)] = 0
for a in A:
ndp = [-INF]*(K+1)*2
for k in range(K+1):
ndp[ind(k, 0)] = max(dp[ind(k, 0)], dp[ind(k, 1)])
if k == K: break
ndp[ind(k+1, 1)] = dp[ind(k, 0)]+a
dp = ndp[:]
ans = max(dp[ind(K, 0)], dp[ind(K, 1)])
print(ans)
まぬお