結果
| 問題 | 
                            No.1037 exhausted
                             | 
                    
| コンテスト | |
| ユーザー | 
                             双六
                         | 
                    
| 提出日時 | 2020-08-03 00:36:44 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 326 ms / 2,000 ms | 
| コード長 | 853 bytes | 
| コンパイル時間 | 457 ms | 
| コンパイル使用メモリ | 82,272 KB | 
| 実行使用メモリ | 135,808 KB | 
| 最終ジャッジ日時 | 2024-07-20 01:34:51 | 
| 合計ジャッジ時間 | 5,105 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")
def getlist():
	return list(map(int, input().split()))
#処理内容
def main():
	N, V, L = getlist()
	DP = [[INF] * (V + 1) for i in range(N + 2)]
	DP[0][V] = 0
	xnow = 0
	for i in range(1, N + 1):
		x, v, w = getlist()
		for j in range(V, -1, -1):
			if j + (x - xnow) <= V:
				DP[i][j] = min(DP[i][j], DP[i - 1][j + (x - xnow)])
			DP[i][min(V, j + v)] = min(DP[i][min(V, j + v)], DP[i][j] + w)
			# if j >= v:
			# 	DP[i][j] = min(DP[i][j], DP[i][j - v] + w)
		xnow = x
	for j in range(V + 1):
		if j + (L - xnow) <= V:
			DP[N + 1][j] = min(DP[N + 1][j], DP[N][j + (L - xnow)])
	# print(DP)
	ans = min(DP[-1])
	if ans == INF:
		print(-1)
	else:
		print(ans)
if __name__ == '__main__':
	main()
            
            
            
        
            
双六