Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

ABC042A - 和風いろはちゃんイージー

submit_4.livemd

ABC042A - 和風いろはちゃんイージー

Mix.install(
  [
    {:nx, "~> 0.9"},
    {:exla, "~> 0.9"}
  ],
  config: [
    nx: [
      default_backend: EXLA.Backend,
      default_defn_options: [compiler: EXLA]
    ]
  ]
)

問題

回答4

defmodule Main do
  @target Nx.tensor([5, 5, 7], backend: Nx.BinaryBackend)

  def main do
    :stdio
    |> IO.read(:all)
    |> solve()
    |> IO.puts()
  end

  defp split_words(words) do
    String.split(words, " ")
  end

  def solve(input) do
    input
    |> String.trim()
    |> split_words()
    |> Enum.map(&String.to_integer(&1))
    |> Nx.tensor(backend: Nx.BinaryBackend)
    |> Nx.sort()
    |> case do
      @target -> "YES"
      _ -> "NO"
    end
  end
end
"""
5 5 7
"""
|> Main.solve()
|> then(&(&1 == "YES"))
"""
7 7 5
"""
|> Main.solve()
|> then(&(&1 == "NO"))