[Day_36] 백준 덩치 7568_파이썬 ( 각각 입력받는법)

LUNA·2023년 4월 19일
0

https://www.acmicpc.net/problem/7568

코드

import sys
n=int(input())
people=[]

result=[]

for i in range(n):
    we,he=map(int,input().split())
    people.append((we,he))

for i in range(n):
    k = 0
    for j in range(n):
        if people[i][0]<people[j][0] and people[i][1]<people[j][1]:
            k+=1

    result.append(k+1)

print(*result) 

비교 범위 잘 확인하기!!

for문은 이렇게 바꿀 수 있음

for i in people:
    k = 0
    for j in people:
        if i[0]<j[0] and i[1]<j[1]:
            k+=1
profile
Happiness

0개의 댓글