結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 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 4 ms
5,376 KB
testcase_08 AC 9 ms
6,400 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 720 ms
112,540 KB
testcase_12 AC 941 ms
121,728 KB
testcase_13 AC 676 ms
104,192 KB
testcase_14 AC 90 ms
13,984 KB
testcase_15 AC 572 ms
66,804 KB
testcase_16 AC 1,156 ms
106,624 KB
testcase_17 AC 158 ms
23,808 KB
testcase_18 AC 1,456 ms
135,368 KB
testcase_19 AC 541 ms
59,044 KB
testcase_20 AC 95 ms
15,744 KB
testcase_21 AC 16 ms
6,656 KB
testcase_22 AC 27 ms
8,832 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 729 ms
87,808 KB
testcase_25 AC 1,185 ms
161,408 KB
testcase_26 AC 1,372 ms
172,524 KB
testcase_27 AC 1,365 ms
124,664 KB
testcase_28 AC 1,644 ms
172,668 KB
testcase_29 AC 794 ms
77,184 KB
testcase_30 AC 202 ms
27,136 KB
testcase_31 AC 44 ms
27,392 KB
testcase_32 AC 1,258 ms
124,664 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 = Array.init n     (fun _ -> get_int ()) in
    Array.sort (fun x y -> compare y x) d;
    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