[백준] 덩치 (7568번)

단간단간·2024년 3월 26일
0

알고리즘 문제

목록 보기
3/106

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

python

import sys


def function():
    # 전체 사람 수
    N = int(input())

    deongchi = []
    for i in range(N):
        weight, hight = map(int, sys.stdin.readline().split())
        deongchi.append([i, weight, hight])

    # 정렬
    deongchi.sort(key=lambda x: (-x[1], -x[2]))

    # 순위 리스트 세팅
    score_list = [0 for _ in range(N)]

    for i in range(len(deongchi)):
        score = 1

        if i > 0:
            for j in range(i):
                if deongchi[j][1] > deongchi[i][1] and deongchi[j][2] > deongchi[i][2]:
                    score += 1

        score_list[deongchi[i][0]] = score

    print(" ".join(map(str, score_list)))


if __name__ == "__main__":
    function()
profile
simple is best

0개의 댓글