結果

問題 No.1522 Unfairness
ユーザー H3PO4H3PO4
提出日時 2023-10-04 11:42:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 437 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 58,848 KB
最終ジャッジ日時 2023-10-04 11:42:37
合計ジャッジ時間 14,356 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,084 KB
testcase_01 AC 16 ms
7,824 KB
testcase_02 AC 16 ms
7,900 KB
testcase_03 AC 1,714 ms
30,248 KB
testcase_04 AC 399 ms
13,744 KB
testcase_05 AC 142 ms
9,984 KB
testcase_06 AC 26 ms
8,532 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 AC 62 ms
8,900 KB
testcase_10 AC 640 ms
16,680 KB
testcase_11 AC 280 ms
12,064 KB
testcase_12 AC 1,057 ms
22,644 KB
testcase_13 TLE -
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 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

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):
    for m in range(M + 1):
        dp[i + 2][m] = dp[i + 1][m]
    for m in range(M + 1):
        new_m = m + A[i] - A[i + 1]
        if new_m > M:
            continue
        if dp[i + 2][new_m] < dp[i][m] + A[i]:
            dp[i + 2][new_m] = dp[i][m] + A[i]
print(max(dp[N]))
0