結果

問題 No.716 距離
コンテスト
ユーザー gemmaro
提出日時 2020-04-10 07:34:56
言語 Elixir
(1.20.4)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 326 ms / 2,000 ms
+ 984µs
コード長 384 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 497 ms
コンパイル使用メモリ 78,052 KB
実行使用メモリ 67,744 KB
最終ジャッジ日時 2026-10-09 20:03:40
合計ジャッジ時間 15,514 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: 0..-2 has a default step of -1, please write 0..-2//-1 instead
  Main.exs:12: Main.main/0

warning: 1..-1 has a default step of -1, please write 1..-1//-1 instead
  Main.exs:12: Main.main/0

    warning: List.zip/1 is deprecated. Use Enum.zip/1 instead
    │
 12 │     |> (&([Enum.slice(&1, 0..-2), Enum.slice(&1, 1..-1)] |> List.zip())).()
    │                                                                  ~
    │
    └─ Main.exs:12:66: Main.main/0

ソースコード

diff #
raw source code

defmodule Main do
  def main do
    IO.gets("")

    a =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer(&1))

    a
    |> (&([Enum.slice(&1, 0..-2), Enum.slice(&1, 1..-1)] |> List.zip())).()
    |> Enum.map(fn {x, y} -> y - x end)
    |> Enum.min()
    |> IO.puts()

    (List.last(a) - List.first(a))
    |> IO.puts()
  end
end
0