Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. with open('input.txt', 'r', encoding='utf8') as in_f, open('output.txt', 'w') as out_f:
  2. points = [0] * 301
  3. maxx = 0
  4. k = int(in_f.readline())
  5. for line in in_f:
  6. line = line.split()
  7. summ = int(line[-1]) + int(line[-2]) + int(line[-3])
  8. if int(line[-1]) >= 40 and int(line[-2]) >= 40 and int(line[-3]) >= 40:
  9. points[summ] += 1
  10. maxx = max(maxx, summ)
  11. places = sum(points)
  12. if points[maxx] > k:
  13. print(1, file=out_f)
  14. elif places <= k:
  15. print(0, file=out_f)
  16. else:
  17. i = 300
  18. ans = 0
  19. while k > 0:
  20. k -= points[i]
  21. if points[i] != 0 and k >= 0:
  22. ans = i
  23. i -= 1
  24. print(ans, file=out_f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement