結果
問題 | No.1007 コイン集め |
ユーザー | ikd |
提出日時 | 2020-05-04 23:56:58 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 160 ms / 1,500 ms |
コード長 | 1,197 bytes |
コンパイル時間 | 6,515 ms |
コンパイル使用メモリ | 165,548 KB |
実行使用メモリ | 41,656 KB |
最終ジャッジ日時 | 2023-09-07 11:00:14 |
合計ジャッジ時間 | 10,408 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 86 ms
22,856 KB |
testcase_01 | AC | 70 ms
24,560 KB |
testcase_02 | AC | 86 ms
20,948 KB |
testcase_03 | AC | 71 ms
22,592 KB |
testcase_04 | AC | 88 ms
24,872 KB |
testcase_05 | AC | 85 ms
23,032 KB |
testcase_06 | AC | 85 ms
23,000 KB |
testcase_07 | AC | 85 ms
22,940 KB |
testcase_08 | AC | 86 ms
22,824 KB |
testcase_09 | AC | 86 ms
20,968 KB |
testcase_10 | AC | 86 ms
24,892 KB |
testcase_11 | AC | 87 ms
25,008 KB |
testcase_12 | AC | 149 ms
32,756 KB |
testcase_13 | AC | 149 ms
32,824 KB |
testcase_14 | AC | 149 ms
34,804 KB |
testcase_15 | AC | 124 ms
28,928 KB |
testcase_16 | AC | 125 ms
29,108 KB |
testcase_17 | AC | 124 ms
26,924 KB |
testcase_18 | AC | 160 ms
41,656 KB |
testcase_19 | AC | 146 ms
40,016 KB |
testcase_20 | AC | 160 ms
39,484 KB |
testcase_21 | AC | 157 ms
41,108 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).
ソースコード
// 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 = (max (match pa |> Array.tryFindIndexBack (fun x -> x = 0L) with | Some i -> i + 1 | None -> 0) (match pa |> Array.tryFindIndexBack (fun x -> x = 1L) with | Some i -> i | None -> 0)) let r = (min (match sa |> Array.tryFindIndex (fun x -> x = 0L) with | Some i -> i + k | None -> n - 1) (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