結果

問題 No.716 距離
コンテスト
ユーザー gemmaro
提出日時 2020-04-10 07:34:56
言語 Elixir
(1.19.5)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 384 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 892 ms
コンパイル使用メモリ 72,852 KB
実行使用メモリ 64,576 KB
最終ジャッジ日時 2026-06-04 15:09:30
合計ジャッジ時間 16,373 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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