結果
問題 | No.1037 exhausted |
ユーザー | ikd |
提出日時 | 2020-05-02 13:41:34 |
言語 | F# (F# 4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,766 bytes |
コンパイル時間 | 4,860 ms |
コンパイル使用メモリ | 177,680 KB |
実行使用メモリ | 64,416 KB |
最終ジャッジ日時 | 2023-08-28 16:39:56 |
合計ジャッジ時間 | 10,161 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
22,956 KB |
testcase_01 | AC | 77 ms
22,928 KB |
testcase_02 | AC | 90 ms
23,184 KB |
testcase_03 | AC | 78 ms
24,988 KB |
testcase_04 | WA | - |
testcase_05 | AC | 78 ms
22,804 KB |
testcase_06 | AC | 91 ms
23,176 KB |
testcase_07 | WA | - |
testcase_08 | AC | 78 ms
22,776 KB |
testcase_09 | WA | - |
testcase_10 | AC | 91 ms
23,232 KB |
testcase_11 | WA | - |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
コンパイルメッセージ
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 memo = Array2D.create (nn + 1) (v + 1) inf // printfn "%A" stands let rec solve i j = // printfn "%A %A" i j if memo.[i, j] < inf then memo.[i, j] else if i = 0 then if j = v then 0L else inf else let mutable res = inf let d = stands.[i].X - stands.[i - 1].X if j + d <= v then res <- min res (solve (i - 1) (j + d)) if j > 0 && stands.[i].V > 0 then res <- min res ((solve i (max 0 (j - stands.[i].V))) + stands.[i].W) memo.[i, j] <- res res let mutable ans = inf for j = 0 to v do ans <- min ans (solve (nn - 1) j) if ans < inf then printfn "%d" ans else printfn "-1" 0 // return an integer exit code