3 回答
TA贡献2021条经验 获得超8个赞
它对我有用。如果需要,您可以分配 inf 而不是 1000。
if __name__ == '__main__':
d_list=[]
low=[1000,1000]
for _ in range(int(input())):
name = input()
val = float(input())
if val < low[0]:
low[1]=low[0]
low[0]=val
elif val < low[1] and val >low[0]:
low[1]=val
if val<=low[1]:
d_list.append([name,val])
for student in sorted(d_list):
if student[1]==low[1]:
print(student[0])
TA贡献1852条经验 获得超1个赞
no_of_students = int(input())
records = []
for i in range(no_of_students):
name = input()
score = float(input())
records.append([name, score])
records = dict(records)
scores = sorted(set(records.values()))
second_lowest_score = scores[1]
second_lowest_students = [name for name,score in records if
score==second_lowest_score]
second_lowest_students.sort()
for name in second_lowest_students:
print(name)
TA贡献1775条经验 获得超11个赞
t = int(input())
name = []
marks = []
for i in range(t):
n = input()
m = input()
name.append(n)
marks.append(float(m))
d_marks = []
for i in range(t):
if(marks[i] not in d_marks):
d_marks.append(marks[i])
d_marks.sort()
s_min = float(d_marks[1])
l = []
for i in range(t):
if(float(marks[i]) == s_min):
l.append(name[i])
l.sort()
for i in range(len(l)):
print(l[i])
添加回答
举报