結果

問題 No.647 明太子
ユーザー xsd
提出日時 2020-06-29 23:51:47
言語 OCaml
(5.2.1)
結果
AC  
実行時間 48 ms / 4,500 ms
コード長 631 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 21,452 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2024-10-09 01:43:25
合計ジャッジ時間 1,683 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d" (fun n ->
    let ab = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
    Scanf.scanf " %d" (fun m ->
        let hist = Array.make m 0 in
        for j = 0 to m - 1 do
            Scanf.scanf " %d %d" (fun x y ->
                for i = 0 to n - 1 do
                    let a, b = ab.(i) in
                    if x <= a && y >= b then hist.(j) <- hist.(j) + 1
                done
            )
        done;
        let d = Array.fold_left max 0 hist in
        if d = 0 then print_endline "0" else
            Array.iteri (fun i v -> if v = d then Printf.printf "%d\n" (i + 1)) hist
    )
)
0