結果

問題 No.974 最後の日までに
ユーザー chinchilla
提出日時 2020-01-19 15:54:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 475 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 582,000 KB
最終ジャッジ日時 2024-10-04 01:42:42
合計ジャッジ時間 6,691 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other MLE * 1 -- * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())
a, b, c = [], [], []
for i in range(n):
	u, v, w = input().split()
	a.append(int(u))
	b.append(int(v))
	c.append(int(w))

def select(i):
	m = next(i)
	yield m
	for x in i:
		if x[1] > m[1]:
			m = x
			yield m

cd1, cd2 = [], [(0, 0)]
for i in range(n):
	cd1, cd2 = cd2, list(select(heapq.merge(
		((af + b[i], pr - c[i]) for af, pr in cd1),
		((af, pr + a[i]) for af, pr in cd2), reverse = True)))

print(max(af for af, pr in cd2 if pr >= 0))
0