結果

問題 No.2153 何コーダーが何人?
ユーザー noriocnorioc
提出日時 2024-09-02 01:28:22
言語 Elixir
(1.16.2)
結果
AC  
実行時間 743 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 62,068 KB
実行使用メモリ 56,200 KB
最終ジャッジ日時 2024-09-02 01:28:41
合計ジャッジ時間 18,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 613 ms
53,984 KB
testcase_01 AC 640 ms
54,624 KB
testcase_02 AC 688 ms
55,244 KB
testcase_03 AC 699 ms
55,332 KB
testcase_04 AC 704 ms
54,256 KB
testcase_05 AC 681 ms
54,560 KB
testcase_06 AC 743 ms
54,324 KB
testcase_07 AC 717 ms
54,384 KB
testcase_08 AC 673 ms
55,368 KB
testcase_09 AC 720 ms
54,712 KB
testcase_10 AC 678 ms
54,472 KB
testcase_11 AC 731 ms
54,128 KB
testcase_12 AC 682 ms
54,596 KB
testcase_13 AC 715 ms
54,376 KB
testcase_14 AC 679 ms
54,128 KB
testcase_15 AC 709 ms
54,596 KB
testcase_16 AC 710 ms
56,200 KB
testcase_17 AC 725 ms
55,348 KB
testcase_18 AC 726 ms
54,244 KB
testcase_19 AC 597 ms
54,776 KB
testcase_20 AC 617 ms
54,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def input, do: IO.read(:line) |> String.trim
  def ii, do: input() |> String.to_integer
  def li, do: input() |> String.split |> Enum.map(&String.to_integer/1)
  def yn(b), do: IO.puts(if b, do: "Yes", else: "No")

  def main do
    n = ii()
    for _ <- 1..n, reduce: %{} do
      acc ->
        [s, c] = input() |> String.split
        color = String.to_integer(c)
        if Map.has_key?(acc, s) do
          %{acc | s => color}
        else
          Map.put(acc, s, color)
        end
    end
    |> Enum.frequencies_by(fn {_, v} -> v end)
    |> then(fn freq ->
      for i <- 0..7 do
        IO.puts Map.get(freq, i, 0)
      end
    end)
  end
end
0