結果
問題 |
No.3241 Make Multiplication of 8
|
ユーザー |
![]() |
提出日時 | 2025-08-22 22:04:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 886 ms |
コンパイル使用メモリ | 100,132 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-22 22:04:07 |
合計ジャッジ時間 | 3,303 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<long long> cnt(3); long long ans = 0; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; int c = 0; while (a % 2 == 0) { ++c; a /= 2; } if (c >= 3) { ans += b; continue; } cnt[c] += b; } long long tmp = min(cnt[1], cnt[2]); ans += tmp; cnt[1] -= tmp; cnt[2] -= tmp; ans += cnt[1] / 3 + cnt[2] / 2; cout << ans << endl; }