結果

問題 No.1972 Modulo Set
ユーザー simansiman
提出日時 2022-06-11 09:49:26
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 345 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 27,556 KB
最終ジャッジ日時 2023-10-21 17:08:04
合計ジャッジ時間 8,956 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,132 KB
testcase_01 AC 86 ms
16,096 KB
testcase_02 AC 84 ms
16,096 KB
testcase_03 AC 95 ms
17,472 KB
testcase_04 AC 103 ms
18,372 KB
testcase_05 AC 109 ms
18,772 KB
testcase_06 AC 118 ms
20,156 KB
testcase_07 AC 134 ms
22,516 KB
testcase_08 AC 110 ms
19,144 KB
testcase_09 AC 88 ms
16,356 KB
testcase_10 AC 105 ms
18,468 KB
testcase_11 AC 129 ms
22,540 KB
testcase_12 AC 92 ms
17,076 KB
testcase_13 AC 94 ms
16,620 KB
testcase_14 AC 94 ms
16,620 KB
testcase_15 AC 135 ms
22,692 KB
testcase_16 AC 142 ms
23,980 KB
testcase_17 AC 107 ms
18,564 KB
testcase_18 AC 84 ms
16,096 KB
testcase_19 AC 131 ms
22,712 KB
testcase_20 AC 138 ms
23,844 KB
testcase_21 AC 108 ms
19,312 KB
testcase_22 AC 124 ms
21,992 KB
testcase_23 AC 227 ms
27,400 KB
testcase_24 AC 188 ms
19,568 KB
testcase_25 AC 216 ms
22,220 KB
testcase_26 AC 153 ms
26,332 KB
testcase_27 AC 265 ms
27,556 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 = ((i + i) % M == 0) ? [1, counter[i]].min : counter[i]
  cnt_2 = ((j + j) % M == 0) ? [1, counter[j]].min : counter[j]
  ans += [cnt_1, cnt_2].max
end

puts ans
0