結果

問題 No.231 めぐるはめぐる (1)
ユーザー xsdxsd
提出日時 2020-06-20 11:51:03
言語 OCaml
(5.1.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 588 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 21,448 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 09:00:30
合計ジャッジ時間 926 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d" (fun n ->
    let gd = Array.init n (fun v -> Scanf.scanf " %d %d" (fun g d -> g, d, v)) in
    Array.sort (fun (g1, d1, _) (g2, d2, _) ->
        compare (g2 - 30000 * d2) (g1 - 30000 * d1)) gd;
    let rec loop i acc =
        if i = 6 then acc else
            let g, d, _ = gd.(0) in
            loop (i + 1) (acc + g - 30000 * d)
    in
    let k = loop 0 0 in
    if k >= 3000000 then (
        print_endline "YES";
        for i = 0 to 5 do
            let (_, _, q) = gd.(0) in
            Printf.printf "%d\n" (q + 1)
        done
    ) else print_endline "NO"
)
0