ps:problems:boj:11652
카드
| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 11652 |
| 문제명 | 카드 |
| 레벨 | 실버 4 |
| 분류 |
기초 |
| 시간복잡도 | O(n) |
| 인풋사이즈 | n<=100,000 |
| 사용한 언어 | Python |
| 제출기록 | 43472KB / 168ms |
| 최고기록 | 124ms |
| 해결날짜 | 2022/04/09 |
풀이
- 그냥 시키는대로 구현하면 되는 문제
- collections.Counter를 이용해서 구현하되, most_common() 함수는 안쓰는 것이 구현하기 조금 더 편리.
- 시간복잡도는 O(n)
코드
"""Solution code for "BOJ 11652. 카드".
- Problem link: https://www.acmicpc.net/problem/11652
- Solution link: http://www.teferi.net/ps/problems/boj/11652
"""
import collections
import sys
def main():
N = int(sys.stdin.readline())
nums = [int(sys.stdin.readline()) for _ in range(N)]
counter = collections.Counter(nums)
print(max(counter, key=lambda x: (counter[x], -x)))
if __name__ == '__main__':
main()
ps/problems/boj/11652.txt · 마지막으로 수정됨: 2022/04/09 10:29 저자 teferi

토론