結果

問題 No.1007 コイン集め
ユーザー ikdikd
提出日時 2020-05-04 23:42:04
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 4,879 ms
コンパイル使用メモリ 163,532 KB
実行使用メモリ 41,196 KB
最終ジャッジ日時 2023-09-07 09:08:34
合計ジャッジ時間 8,747 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
25,040 KB
testcase_01 AC 72 ms
22,572 KB
testcase_02 AC 87 ms
22,852 KB
testcase_03 AC 73 ms
24,592 KB
testcase_04 AC 94 ms
22,956 KB
testcase_05 AC 88 ms
25,040 KB
testcase_06 AC 88 ms
22,940 KB
testcase_07 AC 88 ms
22,916 KB
testcase_08 AC 90 ms
24,904 KB
testcase_09 AC 88 ms
23,112 KB
testcase_10 AC 89 ms
24,980 KB
testcase_11 AC 88 ms
20,800 KB
testcase_12 AC 154 ms
33,004 KB
testcase_13 AC 151 ms
32,880 KB
testcase_14 AC 153 ms
32,876 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 160 ms
39,460 KB
testcase_19 AC 144 ms
40,004 KB
testcase_20 AC 159 ms
39,508 KB
testcase_21 AC 158 ms
41,196 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 - 1)] 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
        | None ->
            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