結果

問題 No.112 ややこしい鶴亀算
ユーザー taktak
提出日時 2018-05-20 18:08:34
言語 F#
(F# 4.0)
結果
AC  
実行時間 88 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 3,245 ms
コンパイル使用メモリ 153,224 KB
実行使用メモリ 24,892 KB
最終ジャッジ日時 2023-09-11 00:05:56
合計ジャッジ時間 6,501 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
22,876 KB
testcase_01 AC 84 ms
22,940 KB
testcase_02 AC 85 ms
22,916 KB
testcase_03 AC 85 ms
20,772 KB
testcase_04 AC 86 ms
22,816 KB
testcase_05 AC 84 ms
23,052 KB
testcase_06 AC 85 ms
22,956 KB
testcase_07 AC 85 ms
22,808 KB
testcase_08 AC 85 ms
22,932 KB
testcase_09 AC 85 ms
22,804 KB
testcase_10 AC 85 ms
22,920 KB
testcase_11 AC 86 ms
22,876 KB
testcase_12 AC 86 ms
22,816 KB
testcase_13 AC 85 ms
24,844 KB
testcase_14 AC 86 ms
22,964 KB
testcase_15 AC 85 ms
22,836 KB
testcase_16 AC 86 ms
24,892 KB
testcase_17 AC 86 ms
22,840 KB
testcase_18 AC 85 ms
22,856 KB
testcase_19 AC 84 ms
23,012 KB
testcase_20 AC 86 ms
20,964 KB
testcase_21 AC 88 ms
22,956 KB
testcase_22 AC 87 ms
22,904 KB
testcase_23 AC 86 ms
22,860 KB
testcase_24 AC 85 ms
24,892 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let (|Turtle|Crane|) = function | 4 -> Turtle | _ -> Crane 

let N = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int

let fstValue = a.[0]
if a |> Array.forall(fun x -> x = fstValue) then
    let cnt = a |> Array.length
    match fstValue/(N-1) with
    | Turtle -> (0,cnt)
    | Crane  -> (cnt,0)
else
    let isCraneCnt = a |> Array.max
    let craneCnt = a
                   |> Array.where(fun x -> x=isCraneCnt)
                   |> Array.length
    let turtleCnt = N - craneCnt                   
    (craneCnt,turtleCnt)
|> (fun (c,t) -> printfn "%i %i" c t)    
0