結果

問題 No.1007 コイン集め
ユーザー guriceringuricerin
提出日時 2020-03-06 23:09:54
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 14,364 ms
コンパイル使用メモリ 201,132 KB
実行使用メモリ 50,512 KB
最終ジャッジ日時 2024-04-22 10:25:19
合計ジャッジ時間 16,855 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
29,440 KB
testcase_01 AC 52 ms
29,544 KB
testcase_02 AC 50 ms
29,568 KB
testcase_03 AC 53 ms
29,312 KB
testcase_04 AC 53 ms
29,312 KB
testcase_05 AC 53 ms
29,408 KB
testcase_06 AC 52 ms
29,312 KB
testcase_07 AC 51 ms
29,568 KB
testcase_08 AC 52 ms
29,568 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 82 ms
45,184 KB
testcase_13 AC 86 ms
45,312 KB
testcase_14 AC 81 ms
45,184 KB
testcase_15 AC 69 ms
38,376 KB
testcase_16 AC 68 ms
38,240 KB
testcase_17 AC 70 ms
38,260 KB
testcase_18 AC 81 ms
50,512 KB
testcase_19 AC 76 ms
49,484 KB
testcase_20 WA -
testcase_21 AC 80 ms
50,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (308 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 A = reada int64

    let A = Array.append [| 0L |] A
    let A = Array.append A [| 0L |]
    let mutable r = K
    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
    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
    puts ans
    ()

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