You are viewing a single comment's thread. Return to all comments →
scores = {} top2 = [] def logScore(score): global top2 xs = [x for x in top2 if x < score] + [score] + [x for x in top2 if x > score] if len(xs) > 2: scores.pop(xs[2], None) xs.pop() top2 = xs return score <= xs[-1] for _ in range(int(raw_input())): name = raw_input() score = float(raw_input()) if logScore(score): scores[score] = scores.get(score,[]) + [name] for name in sorted(scores[top2[1]]): print name
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →