結果

問題 No.564 背の順
ユーザー gemmarogemmaro
提出日時 2020-04-19 12:31:50
言語 Elixir
(1.16.2)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 1,081 ms
コンパイル使用メモリ 54,828 KB
実行使用メモリ 50,272 KB
最終ジャッジ日時 2023-08-30 00:29:28
合計ジャッジ時間 9,946 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 602 ms
49,532 KB
testcase_01 AC 616 ms
49,972 KB
testcase_02 AC 612 ms
49,192 KB
testcase_03 AC 615 ms
49,264 KB
testcase_04 AC 616 ms
49,184 KB
testcase_05 AC 622 ms
49,336 KB
testcase_06 AC 612 ms
49,336 KB
testcase_07 AC 624 ms
49,596 KB
testcase_08 AC 622 ms
49,508 KB
testcase_09 AC 617 ms
49,632 KB
testcase_10 AC 619 ms
50,088 KB
testcase_11 AC 623 ms
50,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    [h, n] =
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)

    i =
      1..(n - 1)
      |> Enum.map(fn _ ->
        IO.read(:line)
        |> String.trim()
        |> String.to_integer()
      end)

    solve(h, i)
    |> IO.puts()
  end

  def solve(h, i) do
    r = (i |> Enum.count(&(&1 > h))) + 1

    [
      r,
      case r |> to_string |> String.last() |> String.to_integer() do
        1 -> "st"
        2 -> "nd"
        3 -> "rd"
        _ -> "th"
      end
    ]
    |> Enum.join()
  end
end
0