結果
| 問題 | No.182 新規性の虜 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-06 00:36:59 |
| 言語 | Standard ML (MLton 20241230) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,091 bytes |
| 記録 | |
| コンパイル時間 | 3,863 ms |
| コンパイル使用メモリ | 705,212 KB |
| 実行使用メモリ | 38,988 KB |
| 最終ジャッジ日時 | 2026-05-06 00:37:38 |
| 合計ジャッジ時間 | 10,241 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 1 -- * 5 |
ソースコード
structure Bag =
struct
datatype 'a tree = Leaf | Node of 'a * int * 'a tree * 'a tree
val empty = Leaf
fun size Leaf = 0
| size (Node (k, v, left, right)) = 1 + size left + size right
fun add Leaf newKey = Node (newKey, 1, Leaf, Leaf)
| add (Node (nodeKey, nodeValue, left, right)) newKey =
if nodeKey = newKey then (Node (nodeKey, nodeValue + 1, left, right))
else if nodeKey < newKey then Node (nodeKey, nodeValue, left, add right newKey)
else Node (nodeKey, nodeValue, add left newKey, right)
fun values Leaf = []
| values (Node (_, v, left, right)) = [v] @ values left @ values right
end
fun readInt () =
valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)
fun makeBag l =
List.foldl (fn (a, acc) =>
Bag.add acc a)
Bag.empty
l
val () =
let
val n = readInt ()
val a_s = List.tabulate (n, fn _ => readInt ())
val bag = makeBag a_s
val ans = List.length (List.filter (fn v => v = 1) (Bag.values bag))
in
print (Int.toString ans ^ "\n")
end