結果

問題 No.1247 ブロック登り
ユーザー 👑 tute7627tute7627
提出日時 2020-10-19 21:41:40
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 912 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 86,376 KB
実行使用メモリ 304,364 KB
最終ジャッジ日時 2023-09-28 13:29:31
合計ジャッジ時間 39,360 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,972 KB
testcase_01 AC 71 ms
71,256 KB
testcase_02 AC 72 ms
71,148 KB
testcase_03 AC 72 ms
71,276 KB
testcase_04 AC 88 ms
75,892 KB
testcase_05 AC 84 ms
75,928 KB
testcase_06 AC 72 ms
70,800 KB
testcase_07 AC 228 ms
80,648 KB
testcase_08 AC 224 ms
80,188 KB
testcase_09 AC 199 ms
79,136 KB
testcase_10 AC 203 ms
80,004 KB
testcase_11 TLE -
testcase_12 AC 2,945 ms
289,524 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 2,798 ms
279,608 KB
testcase_19 AC 363 ms
112,416 KB
testcase_20 AC 271 ms
92,312 KB
testcase_21 AC 90 ms
75,976 KB
testcase_22 AC 268 ms
84,432 KB
testcase_23 AC 251 ms
83,032 KB
testcase_24 AC 81 ms
75,692 KB
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
inf2 =  -inf // 2
for i in range(k,-1,-1):
    for j in range(n):
        for o in range(n):
            if dp[i][j][o] <= inf2:continue
            v=dp[i][j][o]
            d=abs(j-o)
            if d <= i:dp[i-d][o][j] = max(dp[i-d][o][j], v)
            if j!=o and i>=2 :dp[i-2][j][o] = max(dp[i-2][j][o], v)
            if j<=o and j>0 and i>0: dp[i-1][j-1][o] = max(dp[i-1][j-1][o],v+(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],v+(i-1)*a[j+1])
            if j<=o and j+i<=o:ret[j+i] = max(ret[j+i], v)
            if j>o and j-i>=o:ret[j-i]=max(ret[j-i],v)
for x in ret:
    print(x)   
    
                                              
            
0