Flying Cat Penguin

ゆるゆる仕事、ソフトウェアテスティング関連のことについて綴ります。

AtCoder 修行日記#79

79日目
ABCのC問題に取り組み中。
茶色レベルのD問題も余裕があれば取り組み中。

勉強用のコンテンツはここから。
https://kenkoooo.com/atcoder/#/table/

進捗と一言感想

[C問題] 1問(残り129問)

ABC081:Not so Diverse

特になし

n, k = map(int, input().split())
an = [int(num) for num in input().split()]
 
kind = {}
for a in an:
  if not a in kind:
    kind[a] = 1
  else :
    kind[a] += 1
 
sortedKind = sorted(kind.items(), key=lambda x:x[1])    
 
if len(sortedKind) > k:
  count = 0
  for check in sortedKind[:len(sortedKind)-k]:
    count += check[1]
  print(count)
else :
  print(0)
目標
  • まず、今年中に茶色コーダー
学習方針

以上。