DHistory
[Baekjoon] Sort - 11652 카드 본문
문제
11652번: 카드
준규는 숫자 카드 N장을 가지고 있다. 숫자 카드에는 정수가 하나 적혀있는데, 적혀있는 수는 -262보다 크거나 같고, 262보다 작거나 같다. 준규가 가지고 있는 카드가 주어졌을 때, 가장 많이 가지
www.acmicpc.net
풀이
import sys
from collections import Counter
n = int(sys.stdin.readline().rstrip())
cards = []
for _ in range(n):
cards.append(int(sys.stdin.readline().rstrip()))
def solution(cards):
return sorted(Counter(cards).items(), key=lambda x: (-x[1], x[0]))[0][0]
print(solution(cards))
채점 결과
'Computer Science > Algorithm' 카테고리의 다른 글
[Baekjoon] DP - 14916 거스름돈 (0) | 2023.09.11 |
---|---|
[Baekjoon] Sort, Binary Search - 2776 암기왕 (0) | 2023.09.11 |
[Baekjoon] Sort - 1302 베스트셀러 (0) | 2023.09.09 |
[Baekjoon] Sort - 10825 국영수 (0) | 2023.09.09 |
[Baekjoon] Sort - 1764 듣보잡 (0) | 2023.09.09 |