結果

問題 No.2334 Distinct Cards
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-06-22 07:08:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 221 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 27,248 KB
最終ジャッジ日時 2023-09-12 01:52:36
合計ジャッジ時間 5,966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,112 KB
testcase_01 AC 78 ms
15,168 KB
testcase_02 AC 77 ms
15,304 KB
testcase_03 AC 78 ms
15,108 KB
testcase_04 AC 78 ms
15,136 KB
testcase_05 AC 84 ms
15,136 KB
testcase_06 AC 79 ms
15,096 KB
testcase_07 AC 80 ms
15,196 KB
testcase_08 AC 80 ms
15,168 KB
testcase_09 AC 80 ms
15,076 KB
testcase_10 AC 80 ms
15,028 KB
testcase_11 AC 82 ms
15,096 KB
testcase_12 AC 161 ms
24,984 KB
testcase_13 AC 163 ms
24,944 KB
testcase_14 AC 165 ms
25,028 KB
testcase_15 AC 164 ms
24,880 KB
testcase_16 AC 168 ms
24,852 KB
testcase_17 AC 165 ms
27,136 KB
testcase_18 AC 169 ms
27,248 KB
testcase_19 AC 174 ms
27,220 KB
testcase_20 AC 140 ms
21,760 KB
testcase_21 AC 142 ms
21,672 KB
testcase_22 AC 139 ms
21,824 KB
testcase_23 AC 78 ms
15,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

hs={}
n,k=gets.split(" ").map{|e| e.to_i}
xs=gets.split(" ").map{|e| e.to_i}
xs.each{|x|
	hs[x]=0 if hs.member?(x)==false
	hs[x]+=1
}
vs=hs.values.sort.reverse
s=0
ans=0
vs.each{|v|
	s+=v
	ans+=1
	break if k<=s
}
puts ans
0