結果

問題 No.1037 exhausted
ユーザー 双六双六
提出日時 2020-08-03 00:36:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 141,180 KB
最終ジャッジ日時 2023-09-27 07:26:10
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
71,608 KB
testcase_01 AC 92 ms
71,456 KB
testcase_02 AC 94 ms
71,604 KB
testcase_03 AC 93 ms
71,592 KB
testcase_04 AC 91 ms
71,644 KB
testcase_05 AC 96 ms
71,304 KB
testcase_06 AC 90 ms
71,568 KB
testcase_07 AC 94 ms
71,512 KB
testcase_08 AC 92 ms
71,600 KB
testcase_09 AC 94 ms
71,300 KB
testcase_10 AC 91 ms
71,616 KB
testcase_11 AC 92 ms
71,700 KB
testcase_12 AC 398 ms
134,452 KB
testcase_13 AC 349 ms
135,372 KB
testcase_14 AC 350 ms
139,780 KB
testcase_15 AC 307 ms
126,332 KB
testcase_16 AC 358 ms
126,544 KB
testcase_17 AC 338 ms
141,180 KB
testcase_18 AC 351 ms
132,508 KB
testcase_19 AC 356 ms
131,904 KB
testcase_20 AC 292 ms
110,032 KB
testcase_21 AC 212 ms
100,028 KB
testcase_22 AC 230 ms
100,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0