結果

問題 No.1972 Modulo Set
ユーザー TKG1TKG1
提出日時 2022-06-10 22:24:57
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 16,725 ms
コンパイル使用メモリ 294,700 KB
実行使用メモリ 17,336 KB
最終ジャッジ日時 2023-10-21 05:25:01
合計ジャッジ時間 15,176 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,324 KB
testcase_01 AC 1 ms
4,328 KB
testcase_02 AC 2 ms
4,328 KB
testcase_03 WA -
testcase_04 AC 9 ms
5,204 KB
testcase_05 WA -
testcase_06 AC 16 ms
7,344 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,328 KB
testcase_10 WA -
testcase_11 AC 22 ms
8,968 KB
testcase_12 AC 6 ms
4,328 KB
testcase_13 AC 4 ms
4,328 KB
testcase_14 AC 4 ms
4,328 KB
testcase_15 AC 27 ms
9,672 KB
testcase_16 AC 31 ms
12,184 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,328 KB
testcase_19 AC 24 ms
10,292 KB
testcase_20 AC 32 ms
12,184 KB
testcase_21 AC 14 ms
6,024 KB
testcase_22 WA -
testcase_23 AC 42 ms
16,584 KB
testcase_24 AC 16 ms
6,424 KB
testcase_25 AC 22 ms
9,740 KB
testcase_26 WA -
testcase_27 AC 42 ms
16,708 KB
testcase_28 AC 16 ms
8,656 KB
testcase_29 AC 22 ms
10,216 KB
testcase_30 AC 32 ms
17,336 KB
testcase_31 AC 4 ms
4,328 KB
testcase_32 AC 25 ms
10,120 KB
testcase_33 AC 44 ms
14,396 KB
testcase_34 AC 43 ms
14,396 KB
testcase_35 AC 43 ms
14,396 KB
testcase_36 AC 44 ms
14,392 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]}

at.size.times do |i|
  num, cnt = b[i]
  next at[0] = 1 if num == 0
  next if at[num] == 0

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

puts at.values.sum
0