結果

問題 No.135 とりあえず1次元の問題
ユーザー xsdxsd
提出日時 2020-06-14 23:42:02
言語 OCaml
(5.1.0)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 22,000 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-04-17 08:57:08
合計ジャッジ時間 1,941 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
17,536 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 23 ms
5,888 KB
testcase_22 AC 125 ms
16,640 KB
evil01.txt AC 81 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d" (fun n ->
    let module S = Set.Make (struct type t = int let compare = compare end) in
    let rec loop i acc =
        if i = n then S.elements acc else
            loop (i + 1) (Scanf.scanf " %d" (fun x -> S.add x acc))
    in
    let a = Array.of_list (loop 0 S.empty) in
    let n = Array.length a in
    Printf.printf "%d\n" @@
        if n = 1 then 0 else
            let rec loop i acc =
                if i = n then acc else loop (i + 1) (min acc (a.(i) - a.(i - 1)))
            in
            loop 1 max_int
)
0