結果
問題 | No.1247 ブロック登り |
ユーザー | mkawa2 |
提出日時 | 2021-08-18 18:48:45 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,373 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 514,764 KB |
最終ジャッジ日時 | 2024-04-20 00:07:57 |
合計ジャッジ時間 | 6,471 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
57,472 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 55 ms
57,984 KB |
testcase_03 | AC | 35 ms
51,712 KB |
testcase_04 | AC | 49 ms
63,232 KB |
testcase_05 | AC | 46 ms
61,440 KB |
testcase_06 | AC | 35 ms
52,480 KB |
testcase_07 | AC | 371 ms
96,200 KB |
testcase_08 | AC | 387 ms
100,284 KB |
testcase_09 | AC | 224 ms
84,748 KB |
testcase_10 | AC | 277 ms
84,748 KB |
testcase_11 | MLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**9 md = 998244353 # md = 10**9+7 n, k = LI() aa = LI() dp = [{} for _ in range(k+1)] for i, a in enumerate(aa): dp[k][0, i, i] = a*k def chmax(i, j, l, r, val): now = dp[i].setdefault((j, l, r), -inf) if val > now: dp[i][j, l, r] = val ans = [-inf]*n for i in range(k, -1, -1): for (j, l, r), pre in dp[i].items(): p0 = r-i if j else l+i if l <= p0 <= r: ans[p0] = max(ans[p0], pre) if i == 0: continue # 左に出る d = r-l+1 if j else 1 if l-1 >= 0 and i-d >= 0: chmax(i-d, 0, l-1, r, pre+(i-d)*aa[l-1]) # 右に出る d = 1 if j else r-l+1 if r+1 < n and i-d >= 0: chmax(i-d, 1, l, r+1, pre+(i-d)*aa[r+1]) # 動かない if l != r: chmax(i-2, j, l, r, pre) print(*ans, sep="\n")