Advertisement
AlexG2230954

ДЗ. Задание 7

May 22nd, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from collections import defaultdict
  2.  
  3.  
  4. groups = defaultdict(int) # подсчет отличников в группах
  5. n = int(input()) # количество учащихся
  6. max_amount = 0 # макс. количество отличников
  7. max_groups = set() # список групп с макс. количеством отличников
  8.  
  9. for _ in range(n):
  10.     *student_name, group, mark = input().split()
  11.     group = int(group)
  12.     mark = int(mark)
  13.  
  14.     if mark >= 8:
  15.         groups[group] += 1
  16.  
  17.     if groups[group] > max_amount:
  18.         max_amount = groups[group]
  19.         max_groups = {group,}
  20.  
  21.     if groups[group] == max_amount:
  22.         max_groups.add(group)
  23.  
  24. print(*sorted(max_groups))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement