結果

問題 No.1015 おつりは要らないです
ユーザー ikdikd
提出日時 2020-05-03 11:54:56
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 5,009 ms
コンパイル使用メモリ 160,768 KB
実行使用メモリ 45,160 KB
最終ジャッジ日時 2023-09-02 11:07:13
合計ジャッジ時間 12,749 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
22,568 KB
testcase_01 AC 70 ms
24,732 KB
testcase_02 AC 69 ms
24,552 KB
testcase_03 AC 69 ms
22,600 KB
testcase_04 AC 71 ms
24,676 KB
testcase_05 AC 71 ms
20,456 KB
testcase_06 AC 71 ms
22,628 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 203 ms
39,952 KB
testcase_16 AC 205 ms
42,276 KB
testcase_17 AC 213 ms
42,584 KB
testcase_18 AC 207 ms
40,308 KB
testcase_19 AC 206 ms
40,092 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 70 ms
22,512 KB
testcase_31 AC 159 ms
34,984 KB
testcase_32 AC 162 ms
37,104 KB
testcase_33 AC 209 ms
44,604 KB
testcase_34 AC 70 ms
24,620 KB
testcase_35 AC 68 ms
22,544 KB
testcase_36 AC 69 ms
22,536 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.sortDescending
    |> Array.mapFold (fun rest p ->
        (if rest <= 0 then p, rest else p - v, rest - 1)) z2
    |> 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