提交时间:2024-11-08 12:04:29
运行 ID: 55541
num_patients = int(input()) seniors = [] non_seniors = [] for _ in range(num_patients): patient_info = input().split() patient_id = patient_info[0] age = int(patient_info[1]) if age >= 60: seniors.append((patient_id, age)) else: non_seniors.append((patient_id, age)) seniors.sort(key=lambda x: (-x[1], seniors.index(x))) non_seniors.sort(key=lambda x: non_seniors.index(x)) for senior in seniors: print(senior[0]) for non_senior in non_seniors: print(non_senior[0])