結果
| 問題 |
No.3329 Only the Rightest Choice is Right!!!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-01 16:52:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 849 bytes |
| コンパイル時間 | 573 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 72,484 KB |
| 最終ジャッジ日時 | 2025-11-01 16:52:31 |
| 合計ジャッジ時間 | 3,875 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 73 |
ソースコード
N, X = (int(x) for x in input().split())
V = [int(x) for x in input().split()]
W = [int(x) for x in input().split()]
dp = [[(-1, -1, -1)] * (X + 1)]
dp[0][0] = (0, -1, -1)
for i in range(N - 1, -1, -1):
ndp = dp[-1][:]
for w in range(X - W[i], -1, -1):
if dp[-1][w][0] == -1:
continue
if (
ndp[w + W[i]][0] == -1
or dp[-1][w][0] + V[i] > ndp[w + W[i]][0]
):
ndp[w + W[i]] = (dp[-1][w][0] + V[i], i, dp[-1][w][1])
dp.append(ndp)
result = []
for w in range(X, -1, -1):
if dp[-1][w][0] == -1:
continue
target = dp[-1][w][1]
while target != -1:
if dp[-1][w][1] == target:
result.append(target + 1)
target = dp[-1][w][2]
w -= W[dp[-1][w][1]]
dp.pop()
break
print(len(result))
print(*result)