結果

問題 No.2227 King Kraken's Attack
ユーザー srjywrdnprkt
提出日時 2023-05-05 01:05:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 104,584 KB
最終ジャッジ日時 2025-02-12 17:03:03
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll H, W, la, lb, ka, kb, ans=1e18;
    cin >> H >> W >> la >> lb >> ka >> kb;
    for (ll i=0; i<=H+W; i++){
        ll l=-1, r=H+W, c;
        while(r-l>1){
            c = (l+r)/2;
            if (H*W - min(H, la*i) * min(W, lb*c) <= ka*i + kb*c) r=c;
            else l=c;
        }
        ans = min(ans, r+i);
    }

    cout << ans << endl;

    return 0;
}
0