結果

問題 No.3241 Make Multiplication of 8
ユーザー eve__fuyuki
提出日時 2025-08-26 01:37:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 194,748 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-26 01:37:11
合計ジャッジ時間 3,826 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
}

int main() {
	fast_io();
	int n;
	cin >> n;
	long long cnt[4] = {};
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		int cnt_2 = 0;
		while (a % 2 == 0) {
			a /= 2;
			cnt_2++;
		}
		cnt[min(cnt_2, 3)] += b;
	}
	long long ans = cnt[3];
	long long mi = min(cnt[1], cnt[2]);
	ans += mi;
	cnt[1] -= mi;
	cnt[2] -= mi;
	ans += cnt[1] / 3 + cnt[2] / 2;

	cout << ans << endl;
}
0