結果

問題 No.561 東京と京都
ユーザー guriceringuricerin
提出日時 2020-01-30 13:06:38
言語 F#
(F# 4.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,270 bytes
コンパイル時間 5,175 ms
コンパイル使用メモリ 171,596 KB
実行使用メモリ 24,588 KB
最終ジャッジ日時 2023-10-14 08:23:44
合計ジャッジ時間 6,275 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
22,584 KB
testcase_01 AC 66 ms
22,376 KB
testcase_02 AC 65 ms
22,416 KB
testcase_03 AC 67 ms
24,536 KB
testcase_04 AC 68 ms
22,572 KB
testcase_05 AC 67 ms
22,536 KB
testcase_06 AC 67 ms
22,452 KB
testcase_07 AC 66 ms
22,536 KB
testcase_08 AC 68 ms
22,448 KB
testcase_09 AC 68 ms
22,360 KB
testcase_10 AC 66 ms
22,436 KB
testcase_11 AC 68 ms
22,436 KB
testcase_12 AC 70 ms
22,528 KB
testcase_13 AC 67 ms
24,588 KB
testcase_14 AC 67 ms
22,468 KB
testcase_15 AC 68 ms
24,460 KB
testcase_16 AC 67 ms
22,444 KB
testcase_17 AC 66 ms
22,372 KB
testcase_18 AC 67 ms
24,504 KB
testcase_19 AC 68 ms
22,576 KB
testcase_20 AC 69 ms
22,372 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(24,13): 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(19,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let [| n; d |] = reada int
    let d = int64 d
    let ts = Array.zeroCreate n
    let ks = Array.zeroCreate n
    for i in 0 .. n - 1 do
        let [| t; k |] = reada int64
        ts.[i] <- t
        ks.[i] <- k

    let inf = Int64.MinValue
    let dp = Array2D.init (n + 10) 2 (fun _ _ -> inf)
    dp.[0, 0] <- 0L
    dp.[0, 1] <- -d
    for i in 1 .. n do
        let t, k = ts.[i - 1], ks.[i - 1]
        let a = dp.[i - 1, 0] + t
        let b = dp.[i - 1, 1] + t - d
        dp.[i, 0] <- max a b
        let a = dp.[i - 1, 1] + k
        let b = dp.[i - 1, 0] + k - d
        dp.[i, 1] <- max a b

    let ans = max dp.[n, 0] dp.[n, 1]
    puts ans
    ()

main()
writer.Close()
0