[백준] - 7568 덩치 (Python)

밀루·2023년 8월 19일
0

BOJ

목록 보기
21/43

문제 링크

풀이과정

score 배열을 1로 초기화해서 만든 후 이중 for문을 돌면서 키와 몸무게 모두 작다면 해당 score[i]에 1을 더해주는 식으로 구현했다.

코드

import sys
n = int(sys.stdin.readline().strip())
l1 = []
for _ in range(n):
    x, y = map(int, sys.stdin.readline().split())
    l1.append([x, y])

score = [1]*50

for i in range(n):
    for j in range(n):
        if l1[i][0]<l1[j][0]:
            if l1[i][1]<l1[j][1]:
                score[i]+=1

for i in range(n):
    print(score[i], end=' ')
profile
이밀루의 도전

0개의 댓글