結果

問題 No.1046 Fruits Rush
ユーザー ikdikd
提出日時 2020-06-06 21:21:32
言語 F#
(F# 4.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 3,934 ms
コンパイル使用メモリ 166,756 KB
実行使用メモリ 25,016 KB
最終ジャッジ日時 2023-08-25 01:58:41
合計ジャッジ時間 6,653 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
22,828 KB
testcase_01 AC 83 ms
23,016 KB
testcase_02 AC 85 ms
21,016 KB
testcase_03 AC 87 ms
22,840 KB
testcase_04 AC 84 ms
24,968 KB
testcase_05 AC 86 ms
22,952 KB
testcase_06 AC 85 ms
22,956 KB
testcase_07 AC 85 ms
22,964 KB
testcase_08 AC 84 ms
25,016 KB
testcase_09 AC 85 ms
22,968 KB
testcase_10 AC 85 ms
24,964 KB
testcase_11 AC 86 ms
23,008 KB
testcase_12 AC 86 ms
24,968 KB
testcase_13 AC 85 ms
22,872 KB
testcase_14 AC 82 ms
22,948 KB
testcase_15 AC 84 ms
24,952 KB
testcase_16 AC 83 ms
22,836 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(5,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

[<EntryPoint>]
let main _ =
    let [| n; k |] = stdin.ReadLine().Split(' ') |> Array.map int
    let a = stdin.ReadLine().Split(' ') |> Array.map int

    if a |> Array.forall (fun x -> x < 0) then
        a
        |> Array.max
        |> printfn "%d"
    else
        a
        |> Array.sortDescending
        |> Array.take k
        |> Array.takeWhile (fun x -> x >= 0)
        |> Array.sum
        |> printfn "%d"
    0
0