AcWing 4889. 空调II (python)
原题链接
简单
作者:
严严
,
2024-12-19 14:26:47
,
所有人可见
,
阅读 1
import copy
import itertools
n,M =map(int,input().split())
l1 = [0 for i in range(101)]
l2 = []
l3 = []
res = []
power2m = 2**M
for i in range(n):
s,t,c = map(int,input().split())
for j in range(s,t+1):
l1[j] = c
for i in range(M):
a,b,p,m = map(int,input().split())
l2.append((a,b,p,m))
for i in range(power2m):
l3 = copy.deepcopy(l1)
cost = 0
perms = bin(i)[2:].zfill(M)
for j in range(M):
if perms[j] == '1':
for k in range(l2[j][0],l2[j][1]+1):
l3[k] -= l2[j][2]
cost += l2[j][3]
if max(l3) <= 0:
res.append(cost)
print(min(res))