bounslay

Untitled

Jun 8th, 2023
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. name_points = input().split()
  2. n = int(input())
  3.  
  4. free_spots = name_points[-1]
  5. free_spots = int(free_spots)
  6.  
  7. names = []
  8. points = []
  9. for i in range(n):
  10.     child = input().split()
  11.     names.append(child[0])
  12.     points.append(child[-1])
  13.    
  14.  
  15. points_lst = [int(i) for i in points]
  16.  
  17.  
  18. child_dict = dict(zip(names, points))
  19.  
  20.  
  21. names_approved_childs = []
  22. counter = 0
  23. replacement_key = ''
  24. for key, value in child_dict.items():
  25.  
  26.     while counter < free_spots:
  27.         max_points = max(child_dict, key=child_dict.get)
  28.         names_approved_childs.append(max_points)
  29.         child_dict[max_points] = replacement_key
  30.         counter += 1
  31.    
  32.  
  33.  
  34.  
  35. rest_of_them = []
  36. for key in child_dict:
  37.     if key in names_approved_childs:
  38.         continue
  39.     rest_of_them.append(key)
  40.  
  41.  
  42. print(*names_approved_childs)
  43.  
  44. if len(rest_of_them) != 0:
  45.     print(*rest_of_them)
  46.  
  47. else:
  48.     print('n/a')
Advertisement
Add Comment
Please, Sign In to add comment