結果

問題 No.1015 おつりは要らないです
ユーザー ikdikd
提出日時 2020-05-03 12:01:49
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 6,245 ms
コンパイル使用メモリ 162,356 KB
実行使用メモリ 45,112 KB
最終ジャッジ日時 2023-09-02 11:40:27
合計ジャッジ時間 14,485 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
22,528 KB
testcase_01 AC 73 ms
22,684 KB
testcase_02 AC 72 ms
22,488 KB
testcase_03 AC 73 ms
22,688 KB
testcase_04 AC 73 ms
22,568 KB
testcase_05 AC 73 ms
20,636 KB
testcase_06 AC 71 ms
22,512 KB
testcase_07 AC 73 ms
20,568 KB
testcase_08 AC 73 ms
24,620 KB
testcase_09 AC 74 ms
20,508 KB
testcase_10 AC 232 ms
44,664 KB
testcase_11 AC 233 ms
40,880 KB
testcase_12 AC 223 ms
40,120 KB
testcase_13 AC 228 ms
42,712 KB
testcase_14 AC 234 ms
43,408 KB
testcase_15 AC 222 ms
40,424 KB
testcase_16 AC 228 ms
40,700 KB
testcase_17 AC 233 ms
45,112 KB
testcase_18 AC 227 ms
38,500 KB
testcase_19 AC 226 ms
42,716 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 72 ms
22,532 KB
testcase_31 AC 165 ms
35,064 KB
testcase_32 AC 166 ms
35,000 KB
testcase_33 AC 220 ms
42,608 KB
testcase_34 AC 74 ms
22,684 KB
testcase_35 AC 72 ms
22,456 KB
testcase_36 AC 71 ms
22,492 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(24,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

// v 円の紙幣 x 枚
let solve v x a =
    let b, x2 =
        a
        |> Array.mapFold (fun rest p ->
            (if rest <= 0 || p <= v then
                p, rest
             else
                 let k = Math.Min(rest, p / v)
                 p - k * v, rest - k)) x
    b
    |> Array.sortDescending
    |> Array.mapFold (fun rest p ->
        (if rest <= 0 then p, rest else p - v, rest - 1)) x2
    |> fst
    |> Array.filter (fun p -> p >= 0)

[<EntryPoint>]
let main argv =
    let [| n; x; y; z |] = stdin.ReadLine().Split() |> Array.map int

    let a =
        stdin.ReadLine().Split()
        |> Array.map int
        |> Array.sortDescending

    let b = a |> solve 10000 z
    let c = b |> solve 5000 y
    let d = c |> solve 1000 x
    if d |> Array.isEmpty then printfn "Yes" else printfn "No"
    0 // return an integer exit code
0