結果

問題 No.1972 Modulo Set
ユーザー maguroflymagurofly
提出日時 2022-06-10 22:13:54
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 30,948 KB
最終ジャッジ日時 2023-10-21 05:19:19
合計ジャッジ時間 7,751 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
16,296 KB
testcase_01 AC 88 ms
16,296 KB
testcase_02 AC 87 ms
16,296 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 91 ms
16,556 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 96 ms
16,820 KB
testcase_14 AC 94 ms
16,820 KB
testcase_15 WA -
testcase_16 AC 164 ms
25,284 KB
testcase_17 AC 115 ms
18,972 KB
testcase_18 AC 91 ms
16,296 KB
testcase_19 AC 148 ms
23,360 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 143 ms
22,448 KB
testcase_23 AC 193 ms
28,992 KB
testcase_24 AC 125 ms
21,088 KB
testcase_25 AC 150 ms
23,712 KB
testcase_26 WA -
testcase_27 AC 200 ms
29,392 KB
testcase_28 AC 128 ms
21,456 KB
testcase_29 AC 149 ms
23,612 KB
testcase_30 AC 179 ms
26,896 KB
testcase_31 AC 95 ms
16,560 KB
testcase_32 AC 164 ms
25,188 KB
testcase_33 AC 212 ms
30,948 KB
testcase_34 AC 209 ms
30,944 KB
testcase_35 AC 215 ms
30,948 KB
testcase_36 AC 216 ms
30,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "set"

N, M = gets.split.map(&:to_i)
A = gets.split.map { _1.to_i % M }

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

ans = 0
A.map { |x| [x, M - x].min }.uniq.each do |x|
    if x * 2 == M
        ans += 1
    else
        ans += [count[x], count[-x % M]].max
    end
end

puts ans
0