結果

問題 No.1972 Modulo Set
ユーザー maimai
提出日時 2022-06-10 22:28:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 31,360 KB
最終ジャッジ日時 2024-04-15 08:52:53
合計ジャッジ時間 6,881 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
12,288 KB
testcase_01 AC 97 ms
12,160 KB
testcase_02 AC 91 ms
12,288 KB
testcase_03 AC 106 ms
13,312 KB
testcase_04 AC 115 ms
14,080 KB
testcase_05 AC 118 ms
14,464 KB
testcase_06 AC 128 ms
15,872 KB
testcase_07 AC 149 ms
18,176 KB
testcase_08 AC 121 ms
15,104 KB
testcase_09 AC 95 ms
12,288 KB
testcase_10 AC 115 ms
14,080 KB
testcase_11 AC 152 ms
18,176 KB
testcase_12 AC 104 ms
12,800 KB
testcase_13 AC 100 ms
12,416 KB
testcase_14 AC 100 ms
12,928 KB
testcase_15 AC 160 ms
20,224 KB
testcase_16 AC 165 ms
19,968 KB
testcase_17 AC 116 ms
14,976 KB
testcase_18 AC 94 ms
12,160 KB
testcase_19 AC 150 ms
19,200 KB
testcase_20 AC 172 ms
20,608 KB
testcase_21 AC 122 ms
15,360 KB
testcase_22 AC 140 ms
18,688 KB
testcase_23 AC 199 ms
27,776 KB
testcase_24 AC 131 ms
17,664 KB
testcase_25 AC 150 ms
22,400 KB
testcase_26 AC 176 ms
21,504 KB
testcase_27 AC 205 ms
28,032 KB
testcase_28 AC 131 ms
19,200 KB
testcase_29 AC 148 ms
22,272 KB
testcase_30 AC 185 ms
26,496 KB
testcase_31 AC 100 ms
12,416 KB
testcase_32 AC 169 ms
23,424 KB
testcase_33 AC 224 ms
31,360 KB
testcase_34 AC 216 ms
31,232 KB
testcase_35 AC 219 ms
31,360 KB
testcase_36 AC 222 ms
31,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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
0