結果

問題 No.3241 Make Multiplication of 8
ユーザー daiota
提出日時 2025-08-22 21:49:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 1,329 ms
コンパイル使用メモリ 162,964 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-22 21:49:31
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)














int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;




	ll N;
	cin >> N;


	vector<ll> t(2,0);
	ll ans=0;
	for(i=1;i<=N;i++){

		ll A,B;
		cin >> A >> B;

		if(A%8==0) ans+=B;
		else{
			if(A%4==0) t[1]+=B;
			else if(A%2==0) t[0]+=B;
		}

	}


		if(t[0]>=t[1]) ans+=t[1]+(t[0]-t[1])/3;
		else ans+=t[0]+(t[1]-t[0])/2;



		cout << ans << endl;




	return 0;

}





0