結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-06-11 09:51:27 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 436 bytes |
| コンパイル時間 | 148 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 33,280 KB |
| 最終ジャッジ日時 | 2024-09-21 18:24:51 |
| 合計ジャッジ時間 | 6,894 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 16 WA * 18 |
コンパイルメッセージ
Syntax OK
ソースコード
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
checked = Hash.new(false)
counter.each do |i, cnt|
j = M - i
next if checked[j]
checked[i] = true
checked[j] = true
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
siman