본문 바로가기
python-algorithm

백준 13333 Q-인덱스

by 무적김두칠 2022. 12. 12.

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

 

13333번: Q-인덱스

ICPC 대학의 모든 박사과정 학생은 자신이 발표한 논문과 그 논문들의 인용횟수를 고려한 학위 취득 조건을 만족해야 한다. 이를 위해, ICPC 대학은 q-인덱스라는 값을 정의했다. 이 인덱스는 논문

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
from bisect import bisect_left, bisect_right
def sol(n, nums):
    start_num = max(nums)
    for target  in range(start_num, -1-1):
        bigger = n - bisect_right(nums, target) + nums.count(target)
        if bigger >= target:
            return target
 
if __name__ == '__main__':
    n = int(input())
    nums = list(map(int, input().split()))
    nums.sort()
    print(sol(n,nums))
 
cs

이진탐색으로 문제의 조건
k번 이상 인용된 논문이 k편 이상이고 나머지 n − k 편의 논문들 인용회수가 각각 k 번 이하라면, 해당 학생의 q-인덱스는 k이다. "
를 브루탈포스 방식으로 쭉 대입해서 조건에 맞으면 return 하는 방식입니다.

Conditions of the problem with binary search
"If the papers cited more than k times are more than k and the remaining n − k papers each have less than k citations, then the student's q-index is k."
It is a method of substituting all the way in the Brutal Force method and returning if the condition is met.

반응형

'python-algorithm' 카테고리의 다른 글

백준 16208 귀찮음  (0) 2022.12.12
백준 19947 투자의 귀재 배주형  (0) 2022.12.12
백준 14912 숫자 빈도수  (0) 2022.12.10
백준 15719 중복된 숫자  (0) 2022.12.08
백준 25773 Number Maximization  (0) 2022.12.08

댓글