結果

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

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll h, w, x, y, a, b;
    cin >> h >> w >> x >> y >> a >> b;
    ll ans = h + w;
    for (ll i = 0; i <= h + w; i++)
    {
        ll ng = -1, ok = h + w;
        while (abs(ok - ng) > 1)
        {
            int j = (ng + ok) / 2;
            if (h * w - min(h, i * x) * min(w, j * y) <= i * a + j * b)
            {
                ok = j;
            }
            else
            {
                ng = j;
            }
        }
        ans = min(ans, i + ok);
    }
    cout << ans << endl;
}
0