結果
問題 | No.1522 Unfairness |
ユーザー | NatsubiSogan |
提出日時 | 2021-05-09 00:12:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 11,852 KB |
実行使用メモリ | 32,128 KB |
最終ジャッジ日時 | 2023-10-17 09:25:28 |
合計ジャッジ時間 | 7,931 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,144 KB |
testcase_01 | AC | 29 ms
10,144 KB |
testcase_02 | AC | 29 ms
10,144 KB |
testcase_03 | TLE | - |
testcase_04 | AC | 540 ms
15,496 KB |
testcase_05 | AC | 203 ms
12,064 KB |
testcase_06 | AC | 41 ms
10,592 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
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 | -- | - |
ソースコード
INF = 10 ** 18 #入力 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)] #dp配列 w = [a[i] - a[i + 1] for i in range(n - 1)] #重さ v = [a[i] for i in range(n - 1)] #価値 #ナップサックdpの計算 for i in range(n): for j in range(m + 1): if i < n - 1 and j + w[i] <= m: dp[i + 2][j + w[i]] = dp[i][j] + v[i] dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) ans = max(dp[n]) print(ans)