結果

問題 No.1015 おつりは要らないです
ユーザー ikdikd
提出日時 2020-05-03 12:31:33
言語 F#
(F# 4.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 1,058 bytes
コンパイル時間 11,252 ms
コンパイル使用メモリ 197,932 KB
実行使用メモリ 66,944 KB
最終ジャッジ日時 2024-04-29 06:14:35
合計ジャッジ時間 18,345 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
30,840 KB
testcase_01 AC 69 ms
30,460 KB
testcase_02 AC 68 ms
30,464 KB
testcase_03 AC 70 ms
30,848 KB
testcase_04 AC 69 ms
30,592 KB
testcase_05 AC 69 ms
30,592 KB
testcase_06 AC 70 ms
30,720 KB
testcase_07 AC 69 ms
30,588 KB
testcase_08 AC 69 ms
30,592 KB
testcase_09 AC 69 ms
30,592 KB
testcase_10 AC 200 ms
61,824 KB
testcase_11 AC 203 ms
62,716 KB
testcase_12 AC 196 ms
61,052 KB
testcase_13 AC 199 ms
62,176 KB
testcase_14 AC 207 ms
63,104 KB
testcase_15 AC 202 ms
61,312 KB
testcase_16 AC 211 ms
62,060 KB
testcase_17 AC 208 ms
62,824 KB
testcase_18 AC 199 ms
61,824 KB
testcase_19 AC 201 ms
61,568 KB
testcase_20 AC 172 ms
55,552 KB
testcase_21 AC 171 ms
55,168 KB
testcase_22 AC 167 ms
55,536 KB
testcase_23 AC 165 ms
54,528 KB
testcase_24 AC 171 ms
55,936 KB
testcase_25 AC 167 ms
55,296 KB
testcase_26 AC 172 ms
55,164 KB
testcase_27 AC 170 ms
55,040 KB
testcase_28 AC 167 ms
55,288 KB
testcase_29 AC 169 ms
55,552 KB
testcase_30 AC 67 ms
30,336 KB
testcase_31 AC 137 ms
45,440 KB
testcase_32 AC 138 ms
45,420 KB
testcase_33 AC 177 ms
66,944 KB
testcase_34 AC 69 ms
30,720 KB
testcase_35 AC 68 ms
30,460 KB
testcase_36 AC 68 ms
30,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (531 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(32,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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,
                      (if p = v then 2 else 1))
             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