結果
問題 |
No.860 買い物
|
ユーザー |
|
提出日時 | 2019-08-10 00:43:36 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 61 ms / 1,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 21,596 KB |
実行使用メモリ | 8,960 KB |
最終ジャッジ日時 | 2024-10-09 00:46:08 |
合計ジャッジ時間 | 2,230 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
open Scanf open Printf let readint () = scanf " %d" (fun x -> x) let readstr () = scanf " %s" (fun x -> x) let readint2 () = scanf " %d %d" (fun x y -> x, y) let stoa s = Array.init (String.length s) (String.get s) let atos a = String.init (Array.length a) (Array.get a) let inf = max_int / 4 let min3 x y z = min x (min y z) let f (x, y, z) (c, d) = let x' = c + min3 (x + c) (y + c + d) (z + d) in let y' = c + min x (y + d) in let z' = c + min3 (x + c) (y + c + d) (z + d) in x', y', z' let () = let n = readint () in let _, _, ans = Array.init n (fun _ -> readint2 ()) |> Array.fold_left f (0, inf, inf) in printf "%d\n" ans