nq1s788

26 номера задач через одну

May 23rd, 2026
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. data = open('26_21719.txt').readlines()
  2. n = int(data[0])
  3. d = {}
  4. for e in data[1:]:
  5.     student, task = map(int, e.split())
  6.     if student not in d:
  7.         d[student] = []
  8.     d[student].append(task)
  9. mx = 0
  10. best_student = -1
  11. for student in d:
  12.     d[student] = sorted(list(set(d[student])))
  13.     answ = 0
  14.     cur = 1
  15.     for i in range(1, len(d[student])):
  16.         if d[student][i] - d[student][i - 1] == 2:
  17.             cur += 1
  18.             answ = max(answ, cur)
  19.         else:
  20.             cur = 1
  21.     if answ > mx:
  22.         mx = answ
  23.         best_student = student
  24. print(best_student, mx)
Advertisement
Add Comment
Please, Sign In to add comment