結果

問題 No.3683 サーバー代がもったいない!
コンテスト
ユーザー dokukuma
提出日時 2026-09-05 13:32:43
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,011 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 235 ms
コンパイル使用メモリ 95,952 KB
実行使用メモリ 956,108 KB
最終ジャッジ日時 2026-09-05 13:32:58
合計ジャッジ時間 9,805 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 6 TLE * 2 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys, time, random, heapq, math, itertools, copy
from collections import deque, Counter, defaultdict
#from sortedcontainers import SortedSet, SortedList
from bisect import bisect, bisect_left, bisect_right
import heapq as hq
from functools import cache, cmp_to_key
def debug(*x):print('debug:',*x, file=sys.stderr)
sys.setrecursionlimit(300000)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]

N, K = mi()
if N < 2 * K - 1:
    print("Impossible")
    exit()
A = li()
dp = [[[-inf, -inf] for _ in range(K+1)] for _ in range(N+1)]  # 
dp[0][0][0] = 0
for i in range(N):
    for j in range(K):
        # 選ぶ
        dp[i+1][j+1][1] = max(dp[i+1][j+1][1], dp[i][j][0] + A[i])
        #選ばない
        dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0], dp[i][j][1])

debug(dp)

ans = max(dp[-1][-1][0], dp[-1][-1][1])
debug(-inf)

print(ans)
0