結果

問題 No.45 回転寿司
ユーザー regerege
提出日時 2015-10-12 20:57:44
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
WA  
実行時間 -
コード長 713 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,829 ms
コンパイル使用メモリ 218,416 KB
実行使用メモリ 37,748 KB
最終ジャッジ日時 2026-05-18 10:21:09
合計ジャッジ時間 16,717 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 3 WA * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (176 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

    let rec f l p n =
        if p + 3 < List.length l then
            let a = (l.[p+0] + l.[p+2])
            let c = (l.[p+0] + l.[p+3])
            let b = (l.[p+1] + l.[p+3])
            let d = List.max [a;b;c]
            let e =
                if d = a || d = c then 0
                else 1
            f l (p+2+e) (n+l.[p+e])
        elif p + 2 < List.length l then
            n + (max (l.[p] + l.[p+2]) l.[p+1])
        elif p + 1 < List.length l then
            n + (max l.[p] l.[p+1])
        elif p < List.length l then
            n + l.[p]
        else n
    stdin.ReadLine() |> ignore
    let l = stdin.ReadLine().Split([|' '|]) |> Seq.map (int) |> Seq.toList
    f l 0 0
    |> (printfn "%d")
0