Advertisement
Void-voiD

Untitled

Apr 3rd, 2023
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | Source Code | 0 0
  1. def func(i):
  2.     return int(i[2])
  3.  
  4.  
  5. a = open("input.txt", "r")
  6. b = open("output.txt", "w")
  7. res = []
  8. k = int(a.readline())
  9. count = 0
  10.  
  11. for elem in a:
  12.     elem = elem.split()
  13.     if int(elem[2]) > k:
  14.         count += 1
  15.         res.append(elem)
  16.  
  17. res.sort(key=func, reverse=True)
  18. cur = 1
  19. b.write(str(count) + '\n')
  20.  
  21. for elem in res:
  22.     if int(elem[2]) > k:
  23.         if cur != count:
  24.             print(str(cur) + ')', str(elem[1][0]) + '.', str(elem[0]), elem[2], file=b)
  25.         else:
  26.             print(str(cur) + ')', str(elem[1][0]) + '.', str(elem[0]), elem[2], file=b, end='')
  27.         cur += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement