結果

問題 No.1522 Unfairness
ユーザー H3PO4H3PO4
提出日時 2023-10-04 11:49:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 100,200 KB
最終ジャッジ日時 2023-10-04 11:50:10
合計ジャッジ時間 7,749 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,760 KB
testcase_01 AC 135 ms
29,776 KB
testcase_02 AC 134 ms
29,784 KB
testcase_03 AC 147 ms
47,932 KB
testcase_04 AC 137 ms
34,524 KB
testcase_05 AC 136 ms
31,408 KB
testcase_06 AC 137 ms
30,036 KB
testcase_07 AC 148 ms
56,728 KB
testcase_08 AC 155 ms
56,464 KB
testcase_09 AC 137 ms
30,340 KB
testcase_10 AC 141 ms
37,256 KB
testcase_11 AC 137 ms
33,140 KB
testcase_12 AC 144 ms
41,852 KB
testcase_13 AC 157 ms
68,124 KB
testcase_14 AC 136 ms
32,608 KB
testcase_15 AC 178 ms
100,140 KB
testcase_16 AC 181 ms
100,156 KB
testcase_17 AC 178 ms
100,200 KB
testcase_18 AC 178 ms
100,108 KB
testcase_19 AC 179 ms
100,196 KB
testcase_20 AC 179 ms
100,080 KB
testcase_21 AC 131 ms
29,704 KB
testcase_22 AC 131 ms
29,680 KB
testcase_23 AC 134 ms
29,784 KB
testcase_24 AC 133 ms
29,968 KB
testcase_25 AC 134 ms
29,796 KB
testcase_26 AC 131 ms
29,924 KB
testcase_27 AC 133 ms
29,736 KB
testcase_28 AC 131 ms
29,644 KB
testcase_29 AC 131 ms
29,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
dp = np.zeros((N + 1, M + 1), dtype=np.int64)

for i in range(N - 1):
    dp[i + 2] = dp[i + 1]
    diff = A[i] - A[i + 1]
    if diff > M:
        continue
    dp[i + 2, diff:] = np.maximum(dp[i, : M + 1 - diff] + A[i], dp[i + 2, diff:])

print(dp[N].max())
0