結果

問題 No.1007 コイン集め
ユーザー guriceringuricerin
提出日時 2020-03-06 23:05:22
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,499 bytes
コンパイル時間 16,098 ms
コンパイル使用メモリ 201,608 KB
実行使用メモリ 50,704 KB
最終ジャッジ日時 2024-04-22 10:20:40
合計ジャッジ時間 18,754 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
29,568 KB
testcase_01 AC 68 ms
30,848 KB
testcase_02 AC 58 ms
29,312 KB
testcase_03 AC 68 ms
30,848 KB
testcase_04 AC 59 ms
29,568 KB
testcase_05 AC 58 ms
29,568 KB
testcase_06 AC 58 ms
29,312 KB
testcase_07 AC 58 ms
29,440 KB
testcase_08 AC 58 ms
29,440 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 90 ms
45,440 KB
testcase_13 AC 91 ms
45,696 KB
testcase_14 AC 88 ms
45,568 KB
testcase_15 AC 78 ms
38,400 KB
testcase_16 AC 78 ms
38,272 KB
testcase_17 AC 77 ms
38,656 KB
testcase_18 AC 91 ms
50,704 KB
testcase_19 AC 94 ms
49,288 KB
testcase_20 WA -
testcase_21 AC 89 ms
50,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (277 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(23,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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 K = K - 1
    let A = reada int64
    if A.[K] = 0L then
        printfn "0"
        exit 0

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

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

    let ans = A.[li..ri] |> Array.sum
    puts ans
    ()

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