結果

問題 No.116 門松列(1)
ユーザー gemmarogemmaro
提出日時 2020-04-16 19:59:49
言語 Elixir
(1.16.2)
結果
AC  
実行時間 635 ms / 5,000 ms
コード長 496 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 55,644 KB
実行使用メモリ 50,072 KB
最終ジャッジ日時 2023-08-30 00:14:32
合計ジャッジ時間 18,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 612 ms
49,328 KB
testcase_01 AC 610 ms
49,892 KB
testcase_02 AC 610 ms
49,280 KB
testcase_03 AC 612 ms
49,088 KB
testcase_04 AC 611 ms
49,224 KB
testcase_05 AC 616 ms
49,412 KB
testcase_06 AC 619 ms
49,132 KB
testcase_07 AC 616 ms
49,420 KB
testcase_08 AC 626 ms
49,356 KB
testcase_09 AC 605 ms
49,344 KB
testcase_10 AC 615 ms
49,196 KB
testcase_11 AC 615 ms
49,312 KB
testcase_12 AC 624 ms
49,852 KB
testcase_13 AC 601 ms
49,200 KB
testcase_14 AC 618 ms
49,756 KB
testcase_15 AC 623 ms
49,556 KB
testcase_16 AC 635 ms
49,328 KB
testcase_17 AC 633 ms
49,232 KB
testcase_18 AC 621 ms
49,316 KB
testcase_19 AC 619 ms
49,264 KB
testcase_20 AC 610 ms
49,200 KB
testcase_21 AC 610 ms
49,768 KB
testcase_22 AC 606 ms
49,156 KB
testcase_23 AC 615 ms
50,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)

    IO.read(:line)
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> solve
    |> IO.puts()
  end

  defp solve(h) do
    0..(length(h) - 3)
    |> Enum.map(fn i ->
      [x, y, z] = h |> Enum.slice(i, 3)

      cond do
        (x < z && z < y) ||
          (y < z && z < x) ||
          (z < x && x < y) ||
            (y < x && x < z) ->
          1

        true ->
          0
      end
    end)
    |> Enum.sum()
  end
end
0