結果

問題 No.3241 Make Multiplication of 8
ユーザー D M
提出日時 2025-09-12 09:29:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 18,712 ms
コンパイル使用メモリ 318,560 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-09-12 09:30:02
合計ジャッジ時間 15,464 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 998244353;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  ll a1=0,a2=0,a3=0;
  rep(i,n){
    ll a,b;cin>>a>>b;
    ll cnt=0;
    while(a%2==0){
        a/=2;
        cnt++;
    }
    if(cnt==1)a1+=b;
    else if(cnt==2)a2+=b;
    else if(cnt>=3)a3+=b;
  }
  ll c=min(a1,a2);
  cout<<a3+c+(a1-c)/3+(a2-c)/2;
}
0