結果

問題 No.844 split game
ユーザー pekempeypekempey
提出日時 2019-06-28 21:53:48
言語 OCaml
(5.1.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 21,580 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-04-17 08:48:16
合計ジャッジ時間 4,770 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
8,704 KB
testcase_01 AC 33 ms
9,216 KB
testcase_02 AC 76 ms
11,136 KB
testcase_03 AC 54 ms
10,752 KB
testcase_04 AC 30 ms
7,936 KB
testcase_05 AC 85 ms
12,160 KB
testcase_06 AC 27 ms
7,936 KB
testcase_07 AC 24 ms
8,576 KB
testcase_08 AC 15 ms
7,040 KB
testcase_09 AC 63 ms
9,728 KB
testcase_10 AC 90 ms
12,160 KB
testcase_11 AC 87 ms
12,544 KB
testcase_12 AC 60 ms
9,728 KB
testcase_13 AC 37 ms
8,192 KB
testcase_14 AC 37 ms
8,960 KB
testcase_15 AC 89 ms
13,056 KB
testcase_16 AC 91 ms
13,184 KB
testcase_17 AC 95 ms
13,184 KB
testcase_18 AC 95 ms
13,184 KB
testcase_19 AC 93 ms
13,184 KB
testcase_20 AC 92 ms
13,184 KB
testcase_21 AC 93 ms
13,056 KB
testcase_22 AC 94 ms
13,184 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 9 ms
6,400 KB
testcase_25 AC 6 ms
5,504 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 7 ms
6,272 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 7 ms
6,272 KB
testcase_30 AC 8 ms
6,400 KB
testcase_31 AC 8 ms
6,144 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 9 ms
6,272 KB
testcase_34 AC 6 ms
6,144 KB
testcase_35 AC 11 ms
6,528 KB
testcase_36 AC 7 ms
6,144 KB
testcase_37 AC 15 ms
6,784 KB
testcase_38 AC 28 ms
7,936 KB
testcase_39 AC 54 ms
9,984 KB
testcase_40 AC 19 ms
7,936 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 1 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 1 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 1 ms
5,376 KB
testcase_58 AC 2 ms
5,376 KB
testcase_59 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let n, m, a = Scanf.scanf "%d %d %d" (fun x y z -> x, y, z);;

let g = Array.make (n+1) [];;
for i = 1 to m do
  let l, r, p = Scanf.scanf " %d %d %d" (fun x y z -> x-1, y, z) in
  g.(l) <- (r,p)::g.(l);
done;;

let inf = max_int / 4;;
let dp1 = Array.make (n+1) (-inf);;
let dp2 = Array.make (n+1) (-inf);;
dp1.(0) <- 0;;
for i = 0 to n-1 do
  dp2.(i+1) <- max dp2.(i+1) dp1.(i);
  dp2.(i+1) <- max dp2.(i+1) dp2.(i);
  List.iter (fun (r, p) ->
      dp1.(r) <- max dp1.(r) (dp1.(i) + p - a);
      dp1.(r) <- max dp1.(r) (dp2.(i) + p - a*2);
    ) g.(i);
done;;

Printf.printf "%d\n" (max (dp1.(n)+a) dp2.(n));;
0