fork download
  1. import sys
  2.  
  3. class person:
  4. def __init__(self, weight:int, high:int):
  5. self.weight = weight
  6. self.high = high
  7. self.rank = 1
  8.  
  9. n = int(sys.stdin.readline().rstrip()) #개행문자까지 같이 받아서 rstrip 필수
  10. lane = []
  11.  
  12. for i in range(0, n, 1):
  13. a, b = map(int, sys.stdin.readline().rstrip().split())# 공백 기준 나눠서 숫자로 변환
  14. lane.append(person(a, b))
  15.  
  16.  
  17. for i in lane:
  18. for j in lane:
  19. if i == j: continue
  20. if (i.weight < j.weight) and (i.high < j.high):
  21. i.rank = i.rank+1
  22.  
  23. ans = ""
  24. for l in lane:
  25. ans+=(str(l.rank)+" ")
  26. print(ans)
Success #stdin #stdout 0.07s 14168KB
stdin
5
55 185
58 183
88 186
60 175
46 155
stdout
2 2 1 2 5