結果

問題 No.112 ややこしい鶴亀算
ユーザー taktak
提出日時 2018-05-20 17:51:09
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 647 bytes
コンパイル時間 4,980 ms
コンパイル使用メモリ 157,208 KB
実行使用メモリ 27,120 KB
最終ジャッジ日時 2023-09-11 00:05:46
合計ジャッジ時間 8,196 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
23,116 KB
testcase_01 AC 91 ms
23,208 KB
testcase_02 AC 92 ms
23,108 KB
testcase_03 AC 91 ms
25,036 KB
testcase_04 AC 91 ms
25,080 KB
testcase_05 AC 91 ms
25,004 KB
testcase_06 WA -
testcase_07 AC 91 ms
23,084 KB
testcase_08 AC 93 ms
23,204 KB
testcase_09 AC 92 ms
25,012 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 91 ms
22,940 KB
testcase_13 AC 94 ms
25,104 KB
testcase_14 AC 91 ms
23,228 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 92 ms
25,132 KB
testcase_19 AC 91 ms
22,972 KB
testcase_20 AC 90 ms
23,088 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 92 ms
23,112 KB
testcase_24 AC 91 ms
22,928 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 cnts = a 
           |> Array.groupBy(fun x -> x)
           |> Array.map(fun (k,_) -> k)
let gt,lt = (cnts |> Array.max,cnts |> Array.min)
if gt = lt then
    match gt/(N-1) with
        | Turtle -> (0,N)
        | Crane  -> (N,0)
else
    cnts
    |> Array.map(fun x -> x = gt)
    |> (fun x ->
        let crane = x 
                    |> Array.where(fun x -> x) 
                    |> Array.length
        let turtle = N - crane
        (crane,turtle))
|> (fun (c,t) -> printfn "%i %i" c t)
0