結果

問題 No.2227 King Kraken's Attack
ユーザー HIcoder
提出日時 2024-09-28 20:29:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 915 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 111,440 KB
最終ジャッジ日時 2025-02-24 14:04:11
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;

int main(){
    ll H,W,LA,LB,KA,KB;
    cin>>H>>W>>LA>>LB>>KA>>KB;

    ll ans=INF;
    
    for(ll a=0;a<=(H+W);a++){
        ll ub=H+W;//ubは必ず達成できる
        ll lb=-1;
        //今、a回横パンチを行ったとする



        while(ub-lb>1){
            ll mid=(ub+lb)/2;

            ll c=min(H,a*LA)*min(W,mid*LB)+a*KA+mid*KB;
            if(c>=H*W){
                ub=mid;
            }else{
                lb=mid;
            }
        }

        ans=min(ans,a+ub);

    }

    cout<<ans<<endl;
}
0