AcWing 1630. 期终成绩
原题链接
简单
作者:
aac
,
2024-11-24 13:57:39
,
所有人可见
,
阅读 1
class Student:
def __init__(self, student_id):
self.id = student_id
self.g_p = -1
self.g_mid = -1
self.g_final = -1
self.g_total = 0
def __repr__(self): # repr 是 "representation" 的缩写,意为“表示”或“表述”
# 返回一个字符串表示,这里返回所有属性值的元组形式
return f"{self.id} {self.g_p} {self.g_mid} {self.g_final} {self.g_total}"
students = {}
p, m, n = map(int, input().split())
for i in range(p):
id, g = input().split()
g = int(g)
if id not in students:
students[id] = Student(id)
students[id].g_p = g
for i in range(m):
id, g = input().split()
g = int(g)
if id not in students:
students[id] = Student(id)
students[id].g_mid = g
for i in range(n):
id, g = input().split()
g = int(g)
if id not in students:
students[id] = Student(id)
students[id].g_final = g
if students[id].g_mid > g:
students[id].g_total = round(students[id].g_mid * 0.4 + g * 0.6)
else:
students[id].g_total += g
ans = []
for student in students.values():
if student.g_p >= 200 and student.g_total >= 60:
ans.append(student)
ans.sort(key=lambda x: (-x.g_total, x.id))
for student in ans:
print(student) # 这将调用 __repr__ 方法