結果

問題 No.143 豆
コンテスト
ユーザー 3qvwn
提出日時 2019-07-03 15:55:38
言語 Elixir
(1.19.5)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 327 ms / 1,000 ms
コード長 467 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 684 ms
コンパイル使用メモリ 72,132 KB
実行使用メモリ 63,300 KB
最終ジャッジ日時 2026-06-04 14:33:35
合計ジャッジ時間 7,500 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

defmodule Main do
  def main do
    beans_sum = IO.gets("") |> String.trim |> String.split |> Enum.take(2) |> Enum.map(&String.to_integer/1) |> List.foldl(1, fn x, acc -> x * acc end)
    age_sum   = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) |> Enum.sum
    out(beans_sum, age_sum)
  end
  
  def out(beans_sum, age_sum) when beans_sum >= age_sum do
    IO.puts beans_sum-age_sum
  end
  
  def out(_, _) do
    IO.puts -1
  end
end
0