結果
問題 | No.1037 exhausted |
ユーザー | ikd |
提出日時 | 2020-05-02 14:49:31 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 649 ms / 2,000 ms |
コード長 | 1,527 bytes |
コンパイル時間 | 4,259 ms |
コンパイル使用メモリ | 172,980 KB |
実行使用メモリ | 60,224 KB |
最終ジャッジ日時 | 2023-08-28 17:48:56 |
合計ジャッジ時間 | 14,211 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
22,792 KB |
testcase_01 | AC | 76 ms
22,808 KB |
testcase_02 | AC | 92 ms
25,056 KB |
testcase_03 | AC | 79 ms
22,872 KB |
testcase_04 | AC | 92 ms
23,216 KB |
testcase_05 | AC | 79 ms
22,756 KB |
testcase_06 | AC | 92 ms
25,164 KB |
testcase_07 | AC | 89 ms
23,116 KB |
testcase_08 | AC | 78 ms
22,740 KB |
testcase_09 | AC | 91 ms
20,988 KB |
testcase_10 | AC | 91 ms
25,084 KB |
testcase_11 | AC | 94 ms
23,036 KB |
testcase_12 | AC | 647 ms
60,088 KB |
testcase_13 | AC | 649 ms
58,056 KB |
testcase_14 | AC | 642 ms
55,876 KB |
testcase_15 | AC | 635 ms
56,092 KB |
testcase_16 | AC | 638 ms
57,888 KB |
testcase_17 | AC | 639 ms
60,224 KB |
testcase_18 | AC | 640 ms
58,000 KB |
testcase_19 | AC | 644 ms
60,132 KB |
testcase_20 | AC | 610 ms
57,768 KB |
testcase_21 | AC | 611 ms
59,848 KB |
testcase_22 | AC | 613 ms
58,084 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved. /home/judge/data/code/Main.fs(22,18): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _; _|]' may indicate a case not covered by the pattern(s). /home/judge/data/code/Main.fs(18,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _; _|]' may indicate a case not covered by the pattern(s).
ソースコード
// Learn more about F# at http://fsharp.org open System type S = { X: int V: int W: int64 } let min a b = if a < b then a else b let max a b = if a > b then a else b [<EntryPoint>] let main argv = let [| n; v; l |] = stdin.ReadLine().Split() |> Array.map int let mutable stands = [| for i in 1 .. n -> (let [| x; v; w |] = stdin.ReadLine().Split() |> Array.map int { X = x V = v W = w |> int64 }) |] if stands.[0].X > 0 then stands <- Array.append [| { X = 0 V = 0 W = 0 |> int64 } |] stands if stands.[stands.Length - 1].X < l then stands <- Array.append stands [| { X = l V = 0 W = 0 |> int64 } |] let nn = stands.Length let inf = Int64.MaxValue / 2L let mutable dp = Array2D.create nn (v + 1) inf dp.[0, v] <- 0L for i = 1 to (nn - 1) do for j = 0 to v do let d = stands.[i].X - stands.[i - 1].X if j - d >= 0 then dp.[i, j - d] <- dp.[i - 1, j] for j = v downto 0 do let nj = min v (j + stands.[i].V) if nj > j then dp.[i, nj] <- min dp.[i, nj] (dp.[i, j] + stands.[i].W) // printfn "%A" dp // printfn "%A" stands let ans = dp.[nn - 1, *] |> Array.min if ans < inf then printfn "%d" ans else printfn "-1" 0 // return an integer exit code