結果
問題 |
No.3241 Make Multiplication of 8
|
ユーザー |
![]() |
提出日時 | 2025-08-24 00:34:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 610 bytes |
コンパイル時間 | 2,623 ms |
コンパイル使用メモリ | 275,512 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-24 00:34:41 |
合計ジャッジ時間 | 4,363 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; ll t1 = 0, t2 = 0, t3 = 0; rep(i, n) { ll a, b; cin >> a >> b; int cnt = 0; while (a % 2 == 0) a /= 2, ++cnt; if (cnt == 1) t1 += b; if (cnt == 2) t2 += b; if (cnt >= 3) t3 += b; } ll ans = t3; { ll t = min(t1, t2); ans += t, t1 -= t, t2 -= t; } ans += t1 / 3, t1 %= 3; ans += t2 / 2, t2 %= 2; cout << ans << '\n'; return 0; }