結果

問題 No.1015 おつりは要らないです
ユーザー ikdikd
提出日時 2020-05-03 11:52:16
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 6,751 ms
コンパイル使用メモリ 158,168 KB
実行使用メモリ 43,064 KB
最終ジャッジ日時 2023-09-02 11:02:22
合計ジャッジ時間 14,316 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
24,520 KB
testcase_01 AC 72 ms
24,648 KB
testcase_02 AC 71 ms
20,428 KB
testcase_03 AC 72 ms
24,548 KB
testcase_04 AC 72 ms
20,388 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 73 ms
24,728 KB
testcase_08 AC 72 ms
22,500 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 207 ms
41,760 KB
testcase_16 AC 208 ms
42,116 KB
testcase_17 AC 212 ms
40,532 KB
testcase_18 AC 207 ms
42,064 KB
testcase_19 AC 210 ms
42,004 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 75 ms
22,552 KB
testcase_31 AC 155 ms
36,632 KB
testcase_32 AC 154 ms
34,628 KB
testcase_33 AC 219 ms
43,064 KB
testcase_34 AC 74 ms
22,556 KB
testcase_35 AC 72 ms
22,640 KB
testcase_36 AC 72 ms
22,632 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, z2 =
        a
        |> Array.mapFold (fun rest p ->
            (if rest <= 0 || p <= v then
                p, rest
             else
                 let k = Math.Min(rest, p / v)
                 p - p / v * k * v, rest - k)) x
    b
    |> Array.mapFold (fun rest p ->
        (if rest <= 0 then p, rest else p - v, rest - 1)) z2
    |> fst
    |> Array.filter (fun p -> p >= 0)
    |> Array.sortDescending

[<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