結果
問題 | No.79 過小評価ダメ・ゼッタイ |
ユーザー |
|
提出日時 | 2020-08-05 14:21:05 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 58 ms / 5,000 ms |
コード長 | 556 bytes |
コンパイル時間 | 403 ms |
コンパイル使用メモリ | 21,836 KB |
実行使用メモリ | 14,780 KB |
最終ジャッジ日時 | 2024-10-09 01:55:25 |
合計ジャッジ時間 | 1,757 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
let () = Scanf.scanf "%d\n" @@ fun n -> let lst = List.fast_sort compare (Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d)) in let ((buf, bcnt),(ans, cnt)) = List.fold_left (fun ((bfr, bcnt), (ans, cnt)) x -> if bfr = x then ((x, bcnt+1), (ans, cnt)) else if bcnt > cnt || (bcnt = cnt && bfr > ans) then ((x, 1), (bfr, bcnt)) else ((x, 1), (ans, cnt))) ((List.hd lst, 1), (List.hd lst, 1)) (List.tl lst) in Printf.printf "%d\n" (if bcnt > cnt || (bcnt = cnt && buf > ans) then buf else ans)