結果

問題 No.1522 Unfairness
ユーザー nasubi24nasubi24
提出日時 2021-05-28 22:54:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,012 KB
最終ジャッジ日時 2024-04-29 21:57:57
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,248 KB
testcase_01 AC 41 ms
52,992 KB
testcase_02 AC 40 ms
53,248 KB
testcase_03 AC 127 ms
76,928 KB
testcase_04 AC 83 ms
76,544 KB
testcase_05 AC 65 ms
71,040 KB
testcase_06 AC 62 ms
69,120 KB
testcase_07 AC 163 ms
76,672 KB
testcase_08 AC 149 ms
76,800 KB
testcase_09 AC 63 ms
69,504 KB
testcase_10 AC 93 ms
76,544 KB
testcase_11 AC 68 ms
73,344 KB
testcase_12 AC 106 ms
76,644 KB
testcase_13 AC 184 ms
76,888 KB
testcase_14 AC 68 ms
73,088 KB
testcase_15 AC 274 ms
76,976 KB
testcase_16 AC 273 ms
76,800 KB
testcase_17 AC 270 ms
77,012 KB
testcase_18 AC 269 ms
76,800 KB
testcase_19 AC 269 ms
76,800 KB
testcase_20 AC 138 ms
76,800 KB
testcase_21 AC 41 ms
53,376 KB
testcase_22 AC 39 ms
53,248 KB
testcase_23 AC 41 ms
53,760 KB
testcase_24 AC 50 ms
62,848 KB
testcase_25 AC 45 ms
59,776 KB
testcase_26 AC 48 ms
61,824 KB
testcase_27 AC 39 ms
53,120 KB
testcase_28 AC 44 ms
59,648 KB
testcase_29 AC 49 ms
62,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
dp1=[-1]*(m+2)
dp1[0]=0
dp2=[-1]*(m+2)
dp2[0]=0
dp2[min(m+1,a[0]-a[1])]=a[0]
for i in range(1,n-1):
    dp3=[-1]*(m+2)
    for j in range(m+1):
        if dp1[j]!=-1:
            dp3[min(m+1,a[i]-a[i+1]+j)]=max(dp3[min(m+1,a[i]-a[i+1]+j)],a[i]+dp1[j])
    dp1=copy.copy(dp2)
    for j in range(m+1):
        dp2[j]=max(dp2[j],dp3[j])
print(max(dp2[:m+1]))
0