結果

問題 No.1972 Modulo Set
ユーザー magurofIymagurofIy
提出日時 2022-06-11 09:37:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 11,900 KB
実行使用メモリ 36,724 KB
最終ジャッジ日時 2023-10-21 16:53:55
合計ジャッジ時間 7,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
16,320 KB
testcase_01 AC 89 ms
16,320 KB
testcase_02 AC 93 ms
16,320 KB
testcase_03 AC 102 ms
17,716 KB
testcase_04 AC 111 ms
18,516 KB
testcase_05 AC 114 ms
18,616 KB
testcase_06 AC 125 ms
20,228 KB
testcase_07 AC 141 ms
22,228 KB
testcase_08 AC 115 ms
18,900 KB
testcase_09 AC 93 ms
16,376 KB
testcase_10 AC 111 ms
18,236 KB
testcase_11 AC 142 ms
22,332 KB
testcase_12 AC 99 ms
17,096 KB
testcase_13 AC 96 ms
16,904 KB
testcase_14 AC 98 ms
16,932 KB
testcase_15 AC 154 ms
24,284 KB
testcase_16 AC 168 ms
25,856 KB
testcase_17 AC 117 ms
19,364 KB
testcase_18 AC 90 ms
16,128 KB
testcase_19 AC 158 ms
24,556 KB
testcase_20 AC 170 ms
26,104 KB
testcase_21 AC 122 ms
19,868 KB
testcase_22 AC 149 ms
23,856 KB
testcase_23 AC 228 ms
34,388 KB
testcase_24 AC 139 ms
21,544 KB
testcase_25 AC 166 ms
26,176 KB
testcase_26 AC 183 ms
27,148 KB
testcase_27 AC 231 ms
34,760 KB
testcase_28 AC 146 ms
24,712 KB
testcase_29 AC 166 ms
26,196 KB
testcase_30 AC 206 ms
32,828 KB
testcase_31 AC 95 ms
16,636 KB
testcase_32 AC 186 ms
27,256 KB
testcase_33 AC 267 ms
36,724 KB
testcase_34 AC 260 ms
36,724 KB
testcase_35 AC 259 ms
36,724 KB
testcase_36 AC 255 ms
36,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

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