結果

問題 No.1007 コイン集め
ユーザー ikdikd
提出日時 2020-05-04 23:54:49
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 5,747 ms
コンパイル使用メモリ 156,424 KB
実行使用メモリ 33,564 KB
最終ジャッジ日時 2023-09-07 10:22:51
合計ジャッジ時間 9,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
16,920 KB
testcase_01 AC 71 ms
16,496 KB
testcase_02 AC 84 ms
16,928 KB
testcase_03 AC 68 ms
16,356 KB
testcase_04 AC 84 ms
16,936 KB
testcase_05 AC 86 ms
16,964 KB
testcase_06 AC 85 ms
16,796 KB
testcase_07 AC 86 ms
17,028 KB
testcase_08 AC 86 ms
16,968 KB
testcase_09 WA -
testcase_10 AC 87 ms
16,860 KB
testcase_11 AC 90 ms
16,964 KB
testcase_12 AC 148 ms
28,716 KB
testcase_13 AC 149 ms
28,568 KB
testcase_14 AC 149 ms
28,708 KB
testcase_15 AC 124 ms
23,236 KB
testcase_16 AC 124 ms
23,260 KB
testcase_17 AC 125 ms
23,284 KB
testcase_18 AC 161 ms
33,564 KB
testcase_19 AC 145 ms
31,852 KB
testcase_20 AC 159 ms
33,424 KB
testcase_21 AC 159 ms
33,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(7,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
    let [| n; kk |] = stdin.ReadLine().Split() |> Array.map int
    let a = stdin.ReadLine().Split() |> Array.map int64

    let k = kk - 1
    if a.[k] = 0L then
        printfn "0"
        exit 0

    let pa =
        if k - 1 >= 0 then a.[..k] else [||]

    let sa =
        if k + 1 < n then a.[(k + 1)..] else [||]

    let l =
        (max
            (match pa |> Array.tryFindIndexBack (fun x -> x = 0L) with
             | Some i -> i + 1
             | None -> 0)
             (match pa |> Array.tryFindIndexBack (fun x -> x = 1L) with
              | Some i -> i
              | None -> 0))

    let r =
        (min
            (match sa |> Array.tryFindIndex (fun x -> x = 0L) with
             | Some i -> i + k
             | None -> n - 1)
             (match sa |> Array.tryFindIndex (fun x -> x = 1L) with
              | Some i -> i + k + 1
              | None -> n - 1))

    if a.[k] = 1L then
        max (a.[l..k] |> Array.sum) (a.[k..r] |> Array.sum) |> printfn "%d"
    else
        a.[l..r]
        |> Array.sum
        |> printfn "%d"

    0 // return an integer exit code
0