結果

問題 No.1972 Modulo Set
ユーザー TKG1TKG1
提出日時 2022-06-10 22:32:30
言語 Crystal
(1.11.2)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 16,768 ms
コンパイル使用メモリ 297,720 KB
実行使用メモリ 16,512 KB
最終ジャッジ日時 2024-04-15 08:53:36
合計ジャッジ時間 16,655 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 8 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 AC 10 ms
5,504 KB
testcase_06 AC 15 ms
7,168 KB
testcase_07 AC 25 ms
9,216 KB
testcase_08 AC 11 ms
5,632 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 22 ms
8,960 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 26 ms
9,216 KB
testcase_16 AC 30 ms
10,624 KB
testcase_17 AC 11 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 23 ms
8,192 KB
testcase_20 AC 30 ms
11,520 KB
testcase_21 AC 13 ms
6,144 KB
testcase_22 AC 21 ms
9,088 KB
testcase_23 AC 41 ms
12,800 KB
testcase_24 AC 15 ms
5,888 KB
testcase_25 AC 22 ms
9,088 KB
testcase_26 AC 35 ms
12,440 KB
testcase_27 AC 41 ms
15,104 KB
testcase_28 AC 16 ms
7,808 KB
testcase_29 AC 23 ms
9,728 KB
testcase_30 AC 31 ms
12,800 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 27 ms
8,704 KB
testcase_33 AC 46 ms
13,952 KB
testcase_34 AC 45 ms
13,952 KB
testcase_35 AC 45 ms
16,512 KB
testcase_36 AC 46 ms
16,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

alias LL = Int64
macro chmin(x, y); {{x}} = {{y}} if {{x}} > {{y}}; end
macro chmax(x, y); {{x}} = {{y}} if {{x}} < {{y}}; end
macro yn(x); {{x}} ? "Yes" : "No"; end

# ---------------------------------------------------- :)

n, m = read_line.split.map(&.to_i64)
a = read_line.split.map(&.to_i64.% m)
amax = a.max
at = a.tally
b = at.to_a.sort_by!{|e| -e[1]}

# p! at
at.size.times do |i|
  num, cnt = b[i]
  next if at[num] == 0
  if (num+num) % m == 0
    at[num] = 1
    next
  end

  j = m - num
  while j <= amax
    if at[j]?
      at[j] = 0
    end
    j += m
  end
end

# p! at
puts at.values.sum
0