結果
問題 |
No.3241 Make Multiplication of 8
|
ユーザー |
![]() |
提出日時 | 2025-08-22 21:07:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 932 bytes |
コンパイル時間 | 2,715 ms |
コンパイル使用メモリ | 276,072 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-22 21:07:49 |
合計ジャッジ時間 | 4,193 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define ll long long const long long mod=998244353; const long long hmod=46216567629137; int solve(ll a){ ll res=0; while(a%2==0){ res++; a/=2; } return res; } int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int N; cin>>N; ll A[N+1],B[N+1]; ll ans=0; int cnt[4]; rep(i,4) cnt[i]=0; for(int i=1;i<=N;i++){ cin>>A[i]>>B[i]; ll c=solve(A[i]); if(c>=3){ cnt[3]+=B[i]; } else if(c==2){ cnt[2]+=B[i]; } else if(c==1){ cnt[1]+=B[i]; } } ans+=cnt[3]; if(cnt[2]>=cnt[1]){ ans+=cnt[1]; cnt[2]-=cnt[1]; ans+=cnt[2]/2; } else{ ans+=cnt[2]; cnt[1]-=cnt[2]; ans+=cnt[1]/3; } cout<<ans<<endl; }