[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค-Lv2] H-index / Python

๐Ÿ“š Problem Solving/Programmers

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - H-Index

H-Index๋Š” ๊ณผํ•™์ž์˜ ์ƒ์‚ฐ์„ฑ๊ณผ ์˜ํ–ฅ๋ ฅ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ง€ํ‘œ์ž…๋‹ˆ๋‹ค. ์–ด๋Š ๊ณผํ•™์ž์˜ H-Index๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ’์ธ h๋ฅผ ๊ตฌํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์œ„ํ‚ค๋ฐฑ๊ณผ1์— ๋”ฐ๋ฅด๋ฉด, H-Index๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌํ•ฉ๋‹ˆ๋‹ค. ์–ด๋–ค ๊ณผํ•™์ž๊ฐ€ ๋ฐœํ‘œ

programmers.co.kr

import sys

input = sys.stdin.readline

citations = list(map(int, input().split()))


def solution(citations):
    citations.sort()
    for i in range(len(citations)):
        if len(citations) - i <= citations[i]:
            return len(citations) - i
    return 0


print(solution(citations))

 

ํ•ด์„ค

์šฐ์„ , ๋ฆฌ์ŠคํŠธ๋ฅผ ์ •๋ ฌํ•œ๋‹ค. ๋ฐ˜๋ณต๋ฌธ์„ ํ†ตํ•ด ํ˜„์žฌ ๊ฐ’์ด ๋ฆฌ์ŠคํŠธ์˜ ๊ธธ์ด - ์ธ๋ฑ์Šค ๊ฐ’๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™์•„์ง€๋Š” ๊ฒฝ์šฐ์— ๊ธธ์ด-์ธ๋ฑ์Šค๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค.

 

h๋ฒˆ ์ดํ•˜๋กœ ์ธ์šฉ๋œ ๋…ผ๋ฌธ์€ ์œ„์—์„œ ์„ค๋ช…ํ•œ ์กฐ๊ฑด์„ ์ถฉ์กฑํ•  ๋•Œ ์ตœ๋Œ“๊ฐ’์ด ๋œ๋‹ค.