結果

問題 No.2334 Distinct Cards
ユーザー rlangevinrlangevin
提出日時 2023-06-02 21:25:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 108,252 KB
最終ジャッジ日時 2023-08-28 02:42:52
合計ジャッジ時間 4,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,552 KB
testcase_01 AC 89 ms
71,248 KB
testcase_02 AC 91 ms
71,640 KB
testcase_03 AC 89 ms
71,560 KB
testcase_04 AC 85 ms
71,800 KB
testcase_05 AC 89 ms
71,476 KB
testcase_06 AC 89 ms
71,316 KB
testcase_07 AC 96 ms
76,352 KB
testcase_08 AC 92 ms
72,180 KB
testcase_09 AC 101 ms
76,384 KB
testcase_10 AC 99 ms
76,304 KB
testcase_11 AC 101 ms
76,432 KB
testcase_12 AC 169 ms
101,652 KB
testcase_13 AC 205 ms
101,672 KB
testcase_14 AC 239 ms
101,796 KB
testcase_15 AC 211 ms
101,504 KB
testcase_16 AC 200 ms
101,904 KB
testcase_17 AC 171 ms
107,988 KB
testcase_18 AC 225 ms
108,252 KB
testcase_19 AC 260 ms
108,012 KB
testcase_20 AC 113 ms
91,168 KB
testcase_21 AC 113 ms
91,332 KB
testcase_22 AC 113 ms
91,200 KB
testcase_23 AC 89 ms
71,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
H = []
D = defaultdict(int)
for a in A:
    D[a] += 1
    
for k, v in D.items():
    heappush(H, (-v, k))
    
ans = set()
while K > 0:
    v, k = heappop(H)
    v = -v
    K -= v
    ans.add(k)
        
print(len(ans))
0