結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー pekempeypekempey
提出日時 2019-12-12 02:18:24
言語 OCaml
(5.1.0)
結果
AC  
実行時間 1,610 ms / 2,500 ms
コード長 1,034 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 21,448 KB
実行使用メモリ 156,544 KB
最終ジャッジ日時 2024-04-17 08:52:47
合計ジャッジ時間 16,361 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 9 ms
6,016 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 711 ms
87,040 KB
testcase_12 AC 925 ms
113,152 KB
testcase_13 AC 711 ms
104,960 KB
testcase_14 AC 97 ms
14,188 KB
testcase_15 AC 607 ms
58,892 KB
testcase_16 AC 1,172 ms
123,932 KB
testcase_17 AC 151 ms
23,552 KB
testcase_18 AC 1,499 ms
138,624 KB
testcase_19 AC 518 ms
61,160 KB
testcase_20 AC 98 ms
16,256 KB
testcase_21 AC 16 ms
6,912 KB
testcase_22 AC 29 ms
8,960 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 773 ms
76,928 KB
testcase_25 AC 1,222 ms
156,288 KB
testcase_26 AC 1,383 ms
156,544 KB
testcase_27 AC 1,335 ms
138,624 KB
testcase_28 AC 1,610 ms
156,416 KB
testcase_29 AC 789 ms
85,452 KB
testcase_30 AC 209 ms
39,424 KB
testcase_31 AC 43 ms
29,312 KB
testcase_32 AC 1,259 ms
146,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let get_int () = Scanf.scanf " %d" (fun x -> x) ;;

let () = 
    let n = get_int () in
    let a = Array.init (n+1) (fun _ -> get_int ()) in
    let b = Array.init (n+1) (fun _ -> get_int ()) in
    let d = List.init n      (fun _ -> get_int ()) |> List.sort (fun x y -> compare y x) |> Array.of_list in
    let l = ref 0 in
    let r = ref (n+1) in
    while !r - !l > 1 do
        let m = (!l + !r)/2 in
        let dp = Array.make_matrix (m+1) (m+1) false in
        dp.(0).(0) <- true;
        for i=0 to m-1 do for j=0 to m-1 do
            if i+j<m && dp.(i).(j) then begin
                if a.(i+1) + b.(j) >= d.(i+j+n-m) then
                    dp.(i+1).(j) <- true;
                if a.(i) + b.(j+1) >= d.(i+j+n-m) then
                    dp.(i).(j+1) <- true;
            end
        done done;
        let mx = ref 0 in
        for i=0 to m do for j=0 to m do
            if dp.(i).(j) then mx := max !mx (i+j)
        done done;
        if !mx = m then l := m else r := m
    done;
    Printf.printf "%d\n" !l
    ;;
0