結果

問題 No.2334 Distinct Cards
ユーザー 👑 tatt61880tatt61880
提出日時 2023-07-11 21:13:00
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 3,398 ms
コンパイル使用メモリ 169,040 KB
実行使用メモリ 13,036 KB
最終ジャッジ日時 2023-10-11 12:21:27
合計ジャッジ時間 7,157 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 109 ms
9,836 KB
testcase_13 AC 111 ms
9,808 KB
testcase_14 AC 109 ms
9,668 KB
testcase_15 AC 109 ms
9,880 KB
testcase_16 AC 109 ms
9,764 KB
testcase_17 AC 135 ms
13,020 KB
testcase_18 AC 133 ms
13,036 KB
testcase_19 AC 132 ms
12,964 KB
testcase_20 AC 41 ms
4,348 KB
testcase_21 AC 41 ms
4,352 KB
testcase_22 AC 41 ms
4,352 KB
testcase_23 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var k: int :: cui@inputInt()
	
	var a: []int :: #[n]int
	for i(0, n - 1)
		do a[i] :: cui@inputInt()
	end for
	
	var dic: dict<int, int> :: #dict<int, int>
	for i(0, n - 1)
		var key: int :: a[i]
		var val: int :: dic.get(key, &)
		do dic.add(key, val + 1)
	end for
	
	var values: []int :: getValues(dic)
	do values.sort()
	do values.reverse()
	
	var ans: int :: 0
	for i(0, ^values - 1)
		do ans :+ 1
		do k :- values[i]
		if(k <= 0)
			break i
		end if
	end for
	
	do cui@print("\{ans}\n")
	
	func getValues(dic: dict<int, int>): []int
		var valueList: List :: #List
		do dic.forEach(callback, valueList $ kuin@Class)
		ret valueList.li.toArray()
		
		class List()
			+var li: list<int>
			*func ctor()
				do me.li :: #list<int>
			end func
		end class
		
		func callback(key: int, value: int, data: kuin@Class): bool
			do (data $ List).li.add(value)
			ret true
		end func
	end func
end func
0