Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

다시 풀어봐

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514’s answer.
  1. User

    다시 풀어봐

  2. Assistant

    알겠습니다! 😃
    H-index 정의에 충실하게 다시 한번 차근차근 풀이해볼게요.


    풀이 아이디어

    1. 논문의 피인용 수를 내림차순으로 정렬
    2. 정렬된 리스트에서 i(0-based)번째 논문의 인용 수가 i+1 이상인지 확인
      • 참이면, “최소 i+1개의 논문이 i+1번 이상 인용”된 상태
      • 거짓이면 더 이상의 h 증가는 불가능
    3. 가장 마지막으로 참이었던 i+1 값을 H-index로 출력

    시간 복잡도:

    • 정렬 O(n log n)
    • 한 번 순회 O(n)
      → 총 O(n log n)

    Python 구현

    import sys
    input = sys.stdin.readline
    
    def h_index(citations):
        # 1) 내림차순 정렬
        citations.sort(reverse=True)
        
        # 2) i번째 논문의 인용수가 (i+1) 이상인 최대 i+1 찾기
        h = 0
        for i, c in enumerate(citations):
            if c >= i + 1:
                h = i + 1
            else:
                break
        return h
    
    def main():
        t = int(input())
        for _ in range(t):
            n = int(input())
            citations = list(map(int, input().split()))
            print(h_index(citations))
    
    if __name__ == "__main__":
        main()
    

    동작 예시

    입력

    2
    5
    3 1 6 5 0
    9
    5 1 4 3 4 10 8 5 2
    

    출력

    3
    4
    
    • 첫 번째 케이스: 정렬 → [6,5,3,1,0], 1~3까지 만족 → H-index = 3
    • 두 번째 케이스: 정렬 → [10,8,5,5,4,4,3,2,1], 1~4까지 만족 → H-index = 4

    이렇게 하면 모든 테스트 케이스에 대해 올바른 H-index를 출력할 수 있습니다. 필요하신 부분 있으면 언제든 말씀해주세요! 😊

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.