結果

問題 No.1007 コイン集め
ユーザー ikdikd
提出日時 2020-05-04 23:46:20
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,108 bytes
コンパイル時間 4,122 ms
コンパイル使用メモリ 160,124 KB
実行使用メモリ 41,480 KB
最終ジャッジ日時 2023-09-07 09:16:54
合計ジャッジ時間 7,925 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 72 ms
22,692 KB
testcase_02 WA -
testcase_03 AC 72 ms
22,528 KB
testcase_04 AC 88 ms
22,876 KB
testcase_05 AC 88 ms
23,008 KB
testcase_06 AC 88 ms
23,040 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 150 ms
32,764 KB
testcase_13 AC 150 ms
34,876 KB
testcase_14 AC 151 ms
34,816 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 158 ms
41,480 KB
testcase_19 AC 144 ms
37,932 KB
testcase_20 AC 160 ms
39,508 KB
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 =
        match pa |> Array.tryFindIndexBack (fun x -> x = 0L) with
        | Some i -> i + 1
        | None ->
            match pa |> Array.tryFindIndexBack (fun x -> x = 1L) with
            | Some i -> i
            | None -> 0

    let r =
        match sa |> Array.tryFindIndex (fun x -> x = 0L) with
        | Some i -> i + k - 1
        | None ->
            match sa |> Array.tryFindIndex (fun x -> x = 1L) with
            | Some i -> i + k
            | 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