結果

問題 No.1007 コイン集め
ユーザー guriceringuricerin
提出日時 2020-03-06 23:21:02
言語 F#
(F# 4.0)
結果
AC  
実行時間 141 ms / 1,500 ms
コード長 1,579 bytes
コンパイル時間 3,562 ms
コンパイル使用メモリ 166,344 KB
実行使用メモリ 41,956 KB
最終ジャッジ日時 2023-08-04 12:58:21
合計ジャッジ時間 6,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
24,584 KB
testcase_01 AC 73 ms
24,488 KB
testcase_02 AC 65 ms
20,500 KB
testcase_03 AC 72 ms
24,516 KB
testcase_04 AC 64 ms
22,664 KB
testcase_05 AC 65 ms
24,596 KB
testcase_06 AC 65 ms
22,528 KB
testcase_07 AC 65 ms
24,656 KB
testcase_08 AC 64 ms
22,472 KB
testcase_09 AC 65 ms
24,512 KB
testcase_10 AC 65 ms
22,736 KB
testcase_11 AC 66 ms
24,584 KB
testcase_12 AC 128 ms
36,052 KB
testcase_13 AC 129 ms
33,932 KB
testcase_14 AC 127 ms
34,076 KB
testcase_15 AC 103 ms
29,292 KB
testcase_16 AC 104 ms
29,304 KB
testcase_17 AC 103 ms
29,492 KB
testcase_18 AC 140 ms
40,860 KB
testcase_19 AC 141 ms
37,540 KB
testcase_20 AC 139 ms
40,620 KB
testcase_21 AC 137 ms
41,956 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(23,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

// -----------------------------------------------------------------------------------------------------

// -----------------------------------------------------------------------------------------------------

let main() =
    let [| N; K |] = reada int
    let A = reada int64
    if A.[K - 1] = 0L then
        printfn "0"
        exit 0

    let A = Array.append [| 0L |] A
    let A = Array.append A [| 0L |]
    let mutable r = K + 1
    let mutable ok = true
    while r < N && ok do
        if A.[r] <= 1L then ok <- false
        if ok then r <- r + 1

    let mutable l = K - 1
    let mutable ok = true
    while l > 0 && ok do
        if A.[l] <= 1L then ok <- false
        if ok then l <- l - 1

    let ans = A.[l..r] |> Array.sum
    let ans2 = max (Array.sum A.[l..K]) (Array.sum A.[K..r])

    let ans =
        if A.[K] = 1L then ans2 else ans
    puts ans
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()
0