結果
問題 | No.1037 exhausted |
ユーザー | ikd |
提出日時 | 2020-05-02 14:52:14 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 638 ms / 2,000 ms |
コード長 | 1,413 bytes |
コンパイル時間 | 3,655 ms |
コンパイル使用メモリ | 175,100 KB |
実行使用メモリ | 60,412 KB |
最終ジャッジ日時 | 2023-08-28 17:52:52 |
合計ジャッジ時間 | 12,516 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
22,808 KB |
testcase_01 | AC | 75 ms
22,908 KB |
testcase_02 | AC | 88 ms
23,212 KB |
testcase_03 | AC | 76 ms
24,792 KB |
testcase_04 | AC | 88 ms
23,248 KB |
testcase_05 | AC | 75 ms
22,772 KB |
testcase_06 | AC | 88 ms
23,236 KB |
testcase_07 | AC | 89 ms
23,040 KB |
testcase_08 | AC | 74 ms
22,872 KB |
testcase_09 | AC | 89 ms
25,216 KB |
testcase_10 | AC | 89 ms
25,152 KB |
testcase_11 | AC | 90 ms
23,156 KB |
testcase_12 | AC | 638 ms
60,412 KB |
testcase_13 | AC | 630 ms
58,116 KB |
testcase_14 | AC | 636 ms
60,136 KB |
testcase_15 | AC | 630 ms
58,212 KB |
testcase_16 | AC | 626 ms
60,032 KB |
testcase_17 | AC | 631 ms
58,220 KB |
testcase_18 | AC | 630 ms
60,232 KB |
testcase_19 | AC | 632 ms
60,168 KB |
testcase_20 | AC | 611 ms
57,740 KB |
testcase_21 | AC | 608 ms
57,888 KB |
testcase_22 | AC | 611 ms
57,960 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 }) |] stands <- Array.append [| { X = 0 V = 0 W = 0 |> int64 } |] stands 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