結果

問題 No.1015 おつりは要らないです
ユーザー ikdikd
提出日時 2020-05-03 12:29:47
言語 F#
(F# 4.0)
結果
WA  
実行時間 -
コード長 978 bytes
コンパイル時間 4,741 ms
コンパイル使用メモリ 164,976 KB
実行使用メモリ 45,880 KB
最終ジャッジ日時 2023-09-02 12:36:48
合計ジャッジ時間 13,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 74 ms
22,552 KB
testcase_02 AC 74 ms
22,576 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 74 ms
24,580 KB
testcase_08 AC 74 ms
24,640 KB
testcase_09 AC 74 ms
22,536 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 249 ms
41,548 KB
testcase_16 AC 255 ms
43,860 KB
testcase_17 AC 259 ms
44,172 KB
testcase_18 AC 257 ms
41,780 KB
testcase_19 AC 254 ms
43,704 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,592 KB
testcase_31 WA -
testcase_32 AC 215 ms
37,928 KB
testcase_33 AC 248 ms
42,404 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(29,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.sortDescending
        |> 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
             let k = Math.Min(rest, p / v)
             p - k * v, rest - k)) 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

    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