結果

問題 No.693 square1001 and Permutation 2
ユーザー wotsushi
提出日時 2018-07-26 22:00:07
言語 Elixir
(1.18.1)
結果
AC  
実行時間 569 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 63,924 KB
実行使用メモリ 56,412 KB
最終ジャッジ日時 2024-12-31 02:08:25
合計ジャッジ時間 8,507 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    _ = IO.gets("") |> String.trim |> String.to_integer
    a = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1)

    ans =
      a
      |> Enum.sort
      |> Enum.with_index(1)
      |> Enum.map(fn {x, i} -> abs(x - i) end)
      |> Enum.sum

    IO.puts ans
  end
end
0