QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49017 | #2281. BnPC | Tice | RE | 0ms | 0kb | Python3 | 1.6kb | 2022-09-19 05:13:08 | 2022-09-19 05:13:09 |
Judging History
answer
def totalPoints(): # calculate total points
total = 0
if len(events) > 0:
for x in range(len(events)):
if attributes[events[i]["name"]] > events[i]["points"]:
total += attributes[events[i]["name"]]
return total
line = input().split(" ")
attrAmount = int(line[0])
points = int(line[1])
attributes = {}
for i in range(attrAmount):
new = input().split(" ")
attributes[new[0]] = int(new[1])
amountOfEvents = int(input())
events = []
highestEvents = {}
for i in range(amountOfEvents):
new = input().split(" ")
if new[0] not in highestEvents or int(new[1]) > highestEvents[new[0]]:
highestEvents[new[0]] = int(new[1])
events.append({
"name": new[0],
"points": int(new[1])
})
pointsNeeded = 0
for currentAttr in attributes:
pointsNeeded += highestEvents[currentAttr] - attributes[currentAttr]
if pointsNeeded > points: # check if we have enough points to pass
print(0)
exit(0)
for currentAttr in attributes: # assign enough point to every attribute to pass
diff = highestEvents[currentAttr] - attributes[currentAttr]
if diff > 0:
attributes[currentAttr] += diff
points -= diff
for i in range(points):
attributesBackUp = attributes.copy()
attributesResult = {}
for currentAttr in attributes:
attributes[currentAttr] += 1
attributesResult[currentAttr] = totalPoints()
attributes = attributesBackUp.copy()
best = max(attributesResult, key=attributesResult.get)
attributes[best] += 1
print(totalPoints())
详细
Test #1:
score: 0
Runtime Error
input:
3 14 THISISTHEONE 8 B 0 C 0 8 THISISTHEONE 10 C 0 B 1 B 0 THISISTHEONE 0 C 1 THISISTHEONE 0 THISISTHEONE 0