提出 #17321448


ソースコード 拡げる

defmodule Main do
  def main do
    [n, _m] =
      IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1)

    IO.read(:line)
    |> String.trim()
    |> String.split(" ")
    |> Enum.map(&String.to_integer/1)
    |> solve(n)
    |> IO.puts()
  end

  @doc ~S"""
  https://atcoder.jp/contests/abc163/tasks/abc163_b

  ## Examples

      iex> Abc163B.solve([5, 6], 41)
      30

      iex> Abc163B.solve([5, 8], 10)
      -1

      iex> Abc163B.solve([5, 6], 11)
      0

  """
  def solve(list, n) do
    do_solve(Enum.sum(list), n)
  end

  defp do_solve(work_sum, n) when n >= work_sum, do: n - work_sum

  defp do_solve(_, _), do: -1
end

提出情報

提出日時
問題 B - Homework
ユーザ awesomey
言語 Elixir (1.10.2)
得点 200
コード長 710 Byte
結果 AC
実行時間 421 ms
メモリ 32100 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 16
セット名 テストケース
Sample sample_01, sample_02, sample_03, sample_04
All hand_01, hand_02, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, sample_01, sample_02, sample_03, sample_04
ケース名 結果 実行時間 メモリ
hand_01 AC 399 ms 30368 KiB
hand_02 AC 391 ms 30460 KiB
random_01 AC 389 ms 32100 KiB
random_02 AC 392 ms 30712 KiB
random_03 AC 383 ms 30636 KiB
random_04 AC 392 ms 30672 KiB
random_05 AC 388 ms 30608 KiB
random_06 AC 385 ms 30528 KiB
random_07 AC 394 ms 30532 KiB
random_08 AC 393 ms 31564 KiB
random_09 AC 388 ms 31568 KiB
random_10 AC 396 ms 31560 KiB
sample_01 AC 403 ms 30768 KiB
sample_02 AC 398 ms 30568 KiB
sample_03 AC 395 ms 30688 KiB
sample_04 AC 421 ms 30764 KiB