結果

問題 No.1522 Unfairness
ユーザー 👑 rin204rin204
提出日時 2022-03-24 15:18:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 137,344 KB
最終ジャッジ日時 2024-04-21 01:19:15
合計ジャッジ時間 4,460 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,352 KB
testcase_01 AC 40 ms
52,096 KB
testcase_02 AC 40 ms
51,712 KB
testcase_03 AC 108 ms
92,672 KB
testcase_04 AC 60 ms
66,304 KB
testcase_05 AC 55 ms
64,640 KB
testcase_06 AC 48 ms
61,312 KB
testcase_07 AC 149 ms
92,032 KB
testcase_08 AC 123 ms
91,228 KB
testcase_09 AC 52 ms
63,744 KB
testcase_10 AC 66 ms
71,040 KB
testcase_11 AC 55 ms
65,280 KB
testcase_12 AC 97 ms
88,064 KB
testcase_13 AC 168 ms
114,560 KB
testcase_14 AC 58 ms
65,408 KB
testcase_15 AC 250 ms
137,060 KB
testcase_16 AC 252 ms
137,344 KB
testcase_17 AC 249 ms
136,960 KB
testcase_18 AC 246 ms
136,832 KB
testcase_19 AC 250 ms
136,832 KB
testcase_20 AC 277 ms
137,280 KB
testcase_21 AC 39 ms
51,584 KB
testcase_22 AC 38 ms
52,096 KB
testcase_23 AC 39 ms
51,968 KB
testcase_24 AC 50 ms
61,952 KB
testcase_25 AC 45 ms
58,112 KB
testcase_26 AC 52 ms
61,440 KB
testcase_27 AC 39 ms
52,352 KB
testcase_28 AC 42 ms
57,600 KB
testcase_29 AC 50 ms
61,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
dp = [[0] * (m + 1) for _ in range(n + 1)]
for i in range(n - 1):
    d = A[i] - A[i + 1]
    for j in range(m + 1):
        dp[i + 2][j] = dp[i + 1][j]
        if j >= d:
            dp[i + 2][j] = max(dp[i + 2][j], dp[i][j - d] + A[i])

print(dp[-1][-1])
    
0