結果

問題 No.1972 Modulo Set
ユーザー simansiman
提出日時 2022-06-11 09:41:53
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 27,564 KB
最終ジャッジ日時 2023-10-21 16:59:47
合計ジャッジ時間 9,594 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,104 KB
testcase_01 AC 88 ms
16,104 KB
testcase_02 AC 87 ms
16,104 KB
testcase_03 WA -
testcase_04 AC 108 ms
18,380 KB
testcase_05 AC 110 ms
18,780 KB
testcase_06 AC 118 ms
20,164 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 131 ms
22,548 KB
testcase_12 AC 94 ms
17,084 KB
testcase_13 AC 96 ms
16,628 KB
testcase_14 AC 94 ms
16,628 KB
testcase_15 AC 133 ms
22,700 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 85 ms
16,104 KB
testcase_19 AC 133 ms
22,720 KB
testcase_20 AC 141 ms
23,852 KB
testcase_21 AC 109 ms
19,320 KB
testcase_22 AC 127 ms
22,000 KB
testcase_23 AC 241 ms
27,408 KB
testcase_24 AC 192 ms
19,576 KB
testcase_25 AC 228 ms
22,228 KB
testcase_26 WA -
testcase_27 AC 279 ms
27,564 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

counter = A.map { |a| a % M }.tally
counter.default = 0

ans = [1, counter[0]].min

1.upto(M / 2) do |i|
  j = M - i

  cnt_1 = (M % (i + i) == 0) ? [1, counter[i]].min : counter[i]
  cnt_2 = (M % (j + j) == 0) ? [1, counter[j]].min : counter[j]
  ans += [cnt_1, cnt_2].max
end

puts ans
0