영단어 암기는 괴로워
내 코드
from sys import stdin
N, M = map(int, stdin.readline().split())
# print(N, M)
dicList = []
dic = {}
for _ in range(N):
word = stdin.readline().strip()
if len(word) >= M:
dicList.append(word)
# print(dicList)
for word in dicList:
if not word in dic:
dic[word] = 1
else:
dic[word] += 1
keys = dic.keys()
# print(dic)
dic = sorted(dic.items(), key=lambda x: (-x[1], -len(x[0]), x[0]))
for word, count in dic:
print(word)
728x90
'Algorithm\CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [20310] 실버3 - 타노스 Python (0) | 2024.05.05 |
---|---|
[Baekjoon] [21921] 실버3 - 블로그 Python (1) | 2024.01.31 |
[Baekjoon] [13305] 실버3 - 주유소 Python (1) | 2024.01.29 |
[Baekjoon] [2164] 실버4 - 카드2 Python (0) | 2024.01.29 |
[Baekjoon] [17266] 실버4 - 어두운 굴다리 Python (1) | 2024.01.29 |