結果

問題 No.1037 exhausted
ユーザー first_vilfirst_vil
提出日時 2020-04-24 22:47:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-04-23 03:44:46
合計ジャッジ時間 3,262 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,336 KB
testcase_01 AC 38 ms
52,956 KB
testcase_02 AC 37 ms
53,108 KB
testcase_03 AC 37 ms
52,744 KB
testcase_04 AC 38 ms
52,740 KB
testcase_05 AC 34 ms
52,880 KB
testcase_06 AC 35 ms
52,836 KB
testcase_07 AC 36 ms
52,612 KB
testcase_08 AC 34 ms
52,796 KB
testcase_09 AC 33 ms
52,612 KB
testcase_10 AC 35 ms
53,136 KB
testcase_11 AC 35 ms
53,084 KB
testcase_12 AC 198 ms
104,980 KB
testcase_13 AC 190 ms
105,244 KB
testcase_14 AC 205 ms
104,972 KB
testcase_15 AC 207 ms
105,132 KB
testcase_16 AC 202 ms
105,016 KB
testcase_17 AC 198 ms
105,164 KB
testcase_18 AC 199 ms
104,840 KB
testcase_19 AC 204 ms
105,472 KB
testcase_20 AC 147 ms
104,180 KB
testcase_21 AC 139 ms
104,624 KB
testcase_22 AC 108 ms
104,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf=int(1e15)
n,lim,goal=map(int,input().split())
xvw=[(0,0,0)]
for _ in range(n):
  xvw.append(tuple(map(int,input().split())))
xvw.append((goal,0,0))
dp=[[inf]*(lim+1) for _ in range(n+2)]
dp[0][lim]=0
for i in range(n+1):
  s=xvw[i][0]
  g,v,w=xvw[i+1]
  for j in range(lim+1):
    if g<=s+j:
      dp[i+1][j-g+s]=min(dp[i+1][j-g+s],dp[i][j])
      dp[i+1][min(j-g+s+v,lim)]=min(dp[i+1][min(j-g+s+v,lim)],dp[i][j]+w)
ans=min(dp[n+1])
print(-1 if ans==inf else ans)
0