結果

問題 No.5 数字のブロック
ユーザー yukiccoyukicco
提出日時 2018-11-17 17:45:22
言語 Elixir
(1.16.2)
結果
AC  
実行時間 664 ms / 5,000 ms
コード長 552 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 54,788 KB
実行使用メモリ 51,192 KB
最終ジャッジ日時 2023-08-29 23:05:15
合計ジャッジ時間 25,246 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 627 ms
49,212 KB
testcase_01 AC 661 ms
50,048 KB
testcase_02 AC 639 ms
49,688 KB
testcase_03 AC 649 ms
50,184 KB
testcase_04 AC 664 ms
49,904 KB
testcase_05 AC 662 ms
50,424 KB
testcase_06 AC 660 ms
49,444 KB
testcase_07 AC 643 ms
50,580 KB
testcase_08 AC 637 ms
50,220 KB
testcase_09 AC 642 ms
49,216 KB
testcase_10 AC 644 ms
51,192 KB
testcase_11 AC 647 ms
49,840 KB
testcase_12 AC 642 ms
50,228 KB
testcase_13 AC 648 ms
50,380 KB
testcase_14 AC 637 ms
49,808 KB
testcase_15 AC 646 ms
49,648 KB
testcase_16 AC 660 ms
50,508 KB
testcase_17 AC 658 ms
50,976 KB
testcase_18 AC 645 ms
50,516 KB
testcase_19 AC 647 ms
50,820 KB
testcase_20 AC 641 ms
49,356 KB
testcase_21 AC 637 ms
50,000 KB
testcase_22 AC 642 ms
49,308 KB
testcase_23 AC 648 ms
49,944 KB
testcase_24 AC 650 ms
49,228 KB
testcase_25 AC 632 ms
49,024 KB
testcase_26 AC 627 ms
49,188 KB
testcase_27 AC 621 ms
49,080 KB
testcase_28 AC 640 ms
49,228 KB
testcase_29 AC 629 ms
49,152 KB
testcase_30 AC 629 ms
48,136 KB
testcase_31 AC 632 ms
48,704 KB
testcase_32 AC 628 ms
49,756 KB
testcase_33 AC 622 ms
49,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
    def numBlock(width, blocks), do: numBlock(width, Enum.sort(blocks), 0, 0)
    defp numBlock(width, blocks, total, acc) do
        if total > width do
            acc - 1
        else
            case blocks do
                [head | tail] -> numBlock(width, tail, total + head, acc + 1)
                _ -> acc
            end
        end
    end
    def main do

        inputs = IO.binread(:all) |> String.split

        [l, _ | ws] = inputs |> Enum.map(&(String.to_integer(&1)))

        IO.puts numBlock(l, ws)

    end
end
0