QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#49017#2281. BnPCTiceRE 0ms0kbPython31.6kb2022-09-19 05:13:082022-09-19 05:13:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-19 05:13:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-09-19 05:13:08]
  • 提交

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

output:


result: