結果

問題 No.1522 Unfairness
ユーザー nasubi24nasubi24
提出日時 2021-05-28 22:49:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-04-25 00:45:55
合計ジャッジ時間 4,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 46 ms
53,760 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 148 ms
76,800 KB
testcase_21 AC 47 ms
52,992 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 56 ms
61,696 KB
testcase_25 AC 53 ms
59,904 KB
testcase_26 AC 57 ms
61,440 KB
testcase_27 RE -
testcase_28 AC 51 ms
60,032 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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])]=max(dp3[min(m+1,a[i]-a[i+1])],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]))
0