AcWing 1262. 鱼塘钓鱼(Python)
原题链接
简单
作者:
习学学
,
2021-02-08 10:18:08
,
所有人可见
,
阅读 395
Python 代码
from heapq import *
n = int(input())
pools = list(map(int, input().split()))
decay = list(map(int, input().split()))
dist = [0] + list(map(int, input().split()))
T = int(input())
res = 0
for end in range(n):
heap = []
for i in range(end+1):
heappush(heap, [-pools[i], decay[i]])
T -= dist[end]
cnt = 0
for j in range(0, T):
p, d = heappop(heap)
if p >= 0: break
cnt -= p
heappush(heap, [p+d, d])
res = max(cnt, res)
print(res)