結果

問題 No.3241 Make Multiplication of 8
ユーザー tomerun
提出日時 2025-08-22 21:24:34
言語 Crystal
(1.14.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 13,249 ms
コンパイル使用メモリ 309,388 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-22 21:24:51
合計ジャッジ時間 15,065 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
cs = Array.new(4, 0i64)
n.times do
  a, b = read_line.split.map(&.to_i)
  c2 = 0
  while a % 2 == 0 && c2 < 3
    a //= 2
    c2 += 1
  end
  cs[c2] += b
end
c12 = {cs[2], cs[1]}.min
ans = cs[3] + c12
cs[2] -= c12
cs[1] -= c12
ans += cs[2] // 2 + cs[1] // 3
puts ans
0