結果
問題 |
No.1972 Modulo Set
|
ユーザー |
|
提出日時 | 2022-06-10 22:28:43 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 184 ms / 2,000 ms |
コード長 | 366 bytes |
コンパイル時間 | 52 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 31,232 KB |
最終ジャッジ日時 | 2024-10-05 01:35:07 |
合計ジャッジ時間 | 5,927 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
Main.rb:14: warning: `+' after local variable or literal is interpreted as binary operator Main.rb:14: warning: even though it seems like unary operator Syntax OK
ソースコード
def lscan; gets.split.map(&:to_i); end n, m = lscan total = 0 cnt0 = 0 cnth = 0 h = Hash.new(0) lscan.each do |a| d = a%m if d == 0 cnt0 += 1 elsif d +d == m cnth += 1 else h[d] += 1 end end total += [0, cnt0-1].max total += [0, cnth-1].max h.keys.each do |k| k2 = m - k total += [h[k],h[k2]].min h[k] = 0 h[k2] = 0 end p n-total