結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー yukicco
提出日時 2018-11-16 22:58:08
言語 Elixir
(1.19.5)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 2,607 ms / 3,000 ms
コード長 504 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 843 ms
コンパイル使用メモリ 72,204 KB
実行使用メモリ 174,864 KB
最終ジャッジ日時 2026-06-04 13:50:14
合計ジャッジ時間 24,287 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: 1..-1 has a default step of -1, please write 1..-1//-1 instead
  Main.exs:15: Main.main/0

ソースコード

diff #
raw source code

defmodule Main do
    def getsAll(device \\ :stdio, prompt), do: getsAll(device, prompt, "")
    defp getsAll(device, prompt, input) do
        x = IO.gets(device, prompt)
        case x do
            {:error, _} -> x
            :eof -> input
            _ -> getsAll(device, prompt, input <> x)
        end
    end
    def main do

        inputs = getsAll(nil) |> String.split

        as = inputs |> Enum.slice(1..-1) |> Enum.map(&(String.to_integer(&1)))

        IO.puts Enum.sum(as)

    end
end
0