PAT 1036
程序员文章站
2022-06-08 12:26:11
...
题意:
给一组学生成绩,求最高分的女生和最低分的男生,并求该分差
注意点
1.若最高分或最低分有多个人,则输出absent和NA!
n = input()
maleg = 101
femaleg = -1
for i in range(0,n):
sinfo = raw_input()
name,sex,ID,grade = sinfo.split()
if sex == 'M':
if int(grade) < maleg:
minnum=1
malename,maleID,maleg=name,ID,int(grade)
elif int(grade) == maleg:
minnum=minnum+1
if sex == 'F':
if int(grade) > femaleg:
maxnum=1
femalename,femaleID,femaleg=name,ID,int(grade)
elif int(grade) == femaleg:
maxnum=maxnum+1
NAf = 0
if femaleg == -1 or maxnum != 1:
print "Absent"
NAf =1
else :
print femalename,femaleID
if maleg == 101 or minnum !=1 :
print "Absent"
NAf =1
else :
print malename,maleID
if NAf == 1:
print "NA"
else :
print femaleg - maleg