結果

問題 No.112 ややこしい鶴亀算
ユーザー tak
提出日時 2018-05-20 18:08:34
言語 F#
(F# 4.0)
結果
AC  
実行時間 354 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 6,616 ms
コンパイル使用メモリ 184,632 KB
実行使用メモリ 34,892 KB
最終ジャッジ日時 2024-06-28 14:44:40
合計ジャッジ時間 16,978 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (228 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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