結果
問題 | No.1247 ブロック登り |
ユーザー | 👑 tute7627 |
提出日時 | 2020-10-19 20:49:45 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 918 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 86,612 KB |
実行使用メモリ | 303,968 KB |
最終ジャッジ日時 | 2023-09-28 13:25:38 |
合計ジャッジ時間 | 6,902 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,448 KB |
testcase_01 | AC | 74 ms
71,172 KB |
testcase_02 | AC | 80 ms
71,032 KB |
testcase_03 | AC | 72 ms
71,112 KB |
testcase_04 | AC | 97 ms
76,352 KB |
testcase_05 | AC | 88 ms
75,528 KB |
testcase_06 | AC | 74 ms
70,800 KB |
testcase_07 | AC | 274 ms
81,036 KB |
testcase_08 | AC | 283 ms
81,592 KB |
testcase_09 | AC | 230 ms
79,984 KB |
testcase_10 | AC | 260 ms
80,456 KB |
testcase_11 | TLE | - |
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 | -- | - |
ソースコード
n, k = map(int, input().split()) a = list(map(int, input().split())) inf = 10**9 dp = [[[-inf]*(n) for _ in range(n)] for _ in range(k+1)] for i in range(n): dp[k][i][i] = a[i] * k; ret = [-inf] * (n) #for _ in range(n):ret.append(-inf) for i in range(k,-1,-1): for j in range(n): for o in range(n): if abs(j-o) <= i:dp[i-abs(j-o)][o][j] = max(dp[i-abs(j-o)][o][j], dp[i][j][o]) if j!=o and i>=2 :dp[i-2][j][o] = max(dp[i-2][j][o], dp[i][j][o]) if j<=o and j>0 and i>0: dp[i-1][j-1][o] = max(dp[i-1][j-1][o],dp[i][j][o]+(i-1)*a[j-1]) if j>=o and j<n-1 and i>0: dp[i-1][j+1][o] = max(dp[i-1][j+1][o],dp[i][j][o]+(i-1)*a[j+1]) if j<=o and j+i<=o:ret[j+i] = max(ret[j+i], dp[i][j][o]) if j>o and j-i>=o:ret[j-i]=max(ret[j-i],dp[i][j][o]) for x in ret: print(x)