結果

問題 No.48 ロボットの操縦
ユーザー 3qvwn3qvwn
提出日時 2019-07-04 22:34:04
言語 Elixir
(1.16.2)
結果
AC  
実行時間 642 ms / 5,000 ms
コード長 650 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 55,976 KB
実行使用メモリ 51,324 KB
最終ジャッジ日時 2023-08-29 23:41:00
合計ジャッジ時間 18,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 620 ms
49,568 KB
testcase_01 AC 624 ms
50,364 KB
testcase_02 AC 628 ms
50,688 KB
testcase_03 AC 625 ms
49,648 KB
testcase_04 AC 628 ms
49,508 KB
testcase_05 AC 616 ms
49,840 KB
testcase_06 AC 631 ms
50,356 KB
testcase_07 AC 637 ms
49,652 KB
testcase_08 AC 630 ms
49,552 KB
testcase_09 AC 634 ms
49,736 KB
testcase_10 AC 642 ms
50,344 KB
testcase_11 AC 633 ms
49,844 KB
testcase_12 AC 622 ms
49,792 KB
testcase_13 AC 621 ms
49,448 KB
testcase_14 AC 625 ms
50,232 KB
testcase_15 AC 632 ms
49,644 KB
testcase_16 AC 630 ms
50,276 KB
testcase_17 AC 626 ms
50,480 KB
testcase_18 AC 629 ms
49,660 KB
testcase_19 AC 622 ms
50,800 KB
testcase_20 AC 635 ms
49,808 KB
testcase_21 AC 631 ms
49,740 KB
testcase_22 AC 631 ms
49,656 KB
testcase_23 AC 630 ms
51,324 KB
testcase_24 AC 639 ms
49,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do 
  def main do
    IO.stream(:stdio, :line) |> Enum.take(3) |> Enum.map(&String.trim/1)|> Enum.map(&String.to_integer/1) |> count |> IO.puts
  end
  
  def count([0, 0, _]) do
    0
  end
  
  def count([0, y, l]) when y > 0 do
    y/l |> abs |> ceil |> trunc
  end
  
  def count([0, y, l]) do
    y/l |> abs |> ceil |> trunc |> (fn num -> num + 2 end).()
  end

  def count([x, 0, l]) do
    x/l |> abs |> ceil |> trunc |> (fn num -> num + 1 end).()
  end

  def count([x, y, l]) do
    count([0, y, l]) + count([x, 0, l]) + rotate(x,y)
  end
  
  def rotate(_,y) when y > 0 do
    0
  end
  
  def rotate(_,_) do
    -1
  end
end
0