Advertisement
Guest User

2A Победитель

a guest
Apr 22nd, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. numOfRounds = int(raw_input())
  5. players = {}
  6. chart = []
  7. round = 1
  8. while round <= numOfRounds:
  9.     data = raw_input()
  10.     name = data.split()[0]
  11.     points = int(data.split()[1])
  12.     if name not in players.keys():
  13.         players[name] = []
  14.     players[name].append([points, round])
  15.     round += 1
  16.  
  17. for name in players:
  18.     score = 0
  19.     for record in players[name]:
  20.         score += record[0]
  21.         lap = record[1]
  22.     chart.append([score, lap, name])
  23.  
  24. chart = sorted(chart, key = lambda item: item[0], reverse = True)
  25.  
  26. maxScore = chart[0][0]
  27. chart = [item for item in chart if item[0] == maxScore]
  28. chart = sorted(chart, key = lambda item: item[1])
  29.  
  30. print chart[0][2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement