結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
|
提出日時 | 2025-09-04 01:12:49 |
言語 | Standard ML (MLton 20210117) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 6,230 ms |
コンパイル使用メモリ | 686,972 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-04 01:13:00 |
合計ジャッジ時間 | 6,360 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun quicksort [] = [] | quicksort (h::tl) = let val (s, b) = List.foldl (fn (x, (small, big)) => if x <= h then (x::small, big) else (small, x::big)) ([], []) tl in (quicksort s) @ [h] @ (quicksort b) end fun takeOutCandies _ [] = 0 | takeOutCandies numToTake (h::tl) = if h = numToTake then List.length tl else if h < numToTake then takeOutCandies (numToTake - h) tl else List.length (h::tl) val () = let val n = readInt () val m = readInt () val c_s = List.tabulate (n, fn _ => readInt ()) val ans = n - takeOutCandies m (quicksort c_s) in print (Int.toString ans ^ "\n") end