結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー taktak
提出日時 2018-06-17 17:10:15
言語 F#
(F# 4.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 4,174 ms
コンパイル使用メモリ 153,376 KB
実行使用メモリ 24,956 KB
最終ジャッジ日時 2023-09-13 06:22:35
合計ジャッジ時間 7,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
22,808 KB
testcase_01 AC 81 ms
22,928 KB
testcase_02 AC 81 ms
22,796 KB
testcase_03 AC 82 ms
24,924 KB
testcase_04 AC 81 ms
22,764 KB
testcase_05 AC 81 ms
22,760 KB
testcase_06 AC 81 ms
20,836 KB
testcase_07 AC 81 ms
22,892 KB
testcase_08 AC 81 ms
22,952 KB
testcase_09 AC 82 ms
24,848 KB
testcase_10 AC 81 ms
22,788 KB
testcase_11 AC 81 ms
22,744 KB
testcase_12 AC 81 ms
22,904 KB
testcase_13 AC 81 ms
22,852 KB
testcase_14 AC 82 ms
22,808 KB
testcase_15 AC 82 ms
22,964 KB
testcase_16 AC 80 ms
22,916 KB
testcase_17 AC 81 ms
22,864 KB
testcase_18 AC 80 ms
22,856 KB
testcase_19 AC 82 ms
22,936 KB
testcase_20 AC 81 ms
24,956 KB
testcase_21 AC 80 ms
22,880 KB
testcase_22 AC 81 ms
24,784 KB
testcase_23 AC 81 ms
24,864 KB
testcase_24 AC 81 ms
22,880 KB
testcase_25 AC 81 ms
22,796 KB
testcase_26 AC 81 ms
24,916 KB
testcase_27 AC 81 ms
24,852 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let safeCheesesNum n k =
    let (|CorrectMsg|ErrorMsg|) (n,k) =
        match 0 < k && k <= n with | true -> CorrectMsg | _ -> ErrorMsg
    match n,k with
    | ErrorMsg   -> 0
    | CorrectMsg ->
        let (|Odd|Eve|) n = match n%2 with | 0 -> Eve | _ -> Odd 
        match n with
        | Eve -> n-2
        | Odd -> if (n/2)+1 = k then n-1 else n-2

let N, K = let t = stdin.ReadLine().Split() |> Array.map int
           in t.[0], t.[1]

safeCheesesNum N K |> printfn "%i"
0