結果

問題 No.1972 Modulo Set
ユーザー magurofIymagurofIy
提出日時 2022-06-11 09:39:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2024-04-15 08:57:33
合計ジャッジ時間 7,439 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
12,416 KB
testcase_01 AC 93 ms
12,160 KB
testcase_02 AC 90 ms
12,160 KB
testcase_03 AC 107 ms
13,696 KB
testcase_04 AC 111 ms
14,208 KB
testcase_05 AC 115 ms
14,720 KB
testcase_06 AC 126 ms
16,384 KB
testcase_07 AC 146 ms
18,560 KB
testcase_08 AC 120 ms
15,360 KB
testcase_09 AC 97 ms
12,288 KB
testcase_10 AC 110 ms
14,336 KB
testcase_11 AC 147 ms
18,688 KB
testcase_12 AC 103 ms
13,056 KB
testcase_13 AC 101 ms
12,672 KB
testcase_14 AC 104 ms
12,672 KB
testcase_15 AC 162 ms
20,608 KB
testcase_16 AC 174 ms
22,144 KB
testcase_17 AC 116 ms
15,360 KB
testcase_18 AC 90 ms
12,288 KB
testcase_19 AC 161 ms
19,968 KB
testcase_20 AC 172 ms
22,272 KB
testcase_21 AC 125 ms
16,000 KB
testcase_22 AC 150 ms
20,096 KB
testcase_23 AC 238 ms
30,848 KB
testcase_24 AC 140 ms
18,304 KB
testcase_25 AC 173 ms
23,040 KB
testcase_26 AC 185 ms
23,680 KB
testcase_27 AC 245 ms
31,232 KB
testcase_28 AC 142 ms
21,376 KB
testcase_29 AC 168 ms
22,912 KB
testcase_30 AC 217 ms
29,440 KB
testcase_31 AC 97 ms
12,544 KB
testcase_32 AC 200 ms
25,600 KB
testcase_33 AC 255 ms
32,128 KB
testcase_34 AC 261 ms
32,000 KB
testcase_35 AC 258 ms
32,256 KB
testcase_36 AC 265 ms
32,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

require "set"

count = Hash.new(0)
A.each do |x|
  count[x % M] += 1
end

ans = 0
added = Set.new
count.each_key do |x|
    y = -x % M
    next if added.include?(x) or added.include?(y)
    added << x << y
    if x == y
        ans += 1
    else
        ans += [count[x], count[y]].max
    end
end

puts ans
0