QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49018 | #2281. BnPC | Tice | RE | 0ms | 0kb | Python3 | 1.5kb | 2022-09-19 05:13:50 | 2022-09-19 05:13:52 |
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())
Details
Tip: Click on the bar to expand more detailed information
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