結果

問題 No.2227 King Kraken's Attack
ユーザー simansiman
提出日時 2023-02-27 18:36:37
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,207 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 138,776 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 09:48:38
合計ジャッジ時間 6,122 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 250 ms
6,944 KB
testcase_15 AC 234 ms
6,940 KB
testcase_16 AC 233 ms
6,940 KB
testcase_17 AC 263 ms
6,944 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 206 ms
6,940 KB
testcase_20 AC 217 ms
6,940 KB
testcase_21 AC 248 ms
6,944 KB
testcase_22 AC 33 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 156 ms
6,944 KB
testcase_25 AC 116 ms
6,944 KB
testcase_26 AC 356 ms
6,940 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 214 ms
6,940 KB
testcase_29 AC 217 ms
6,944 KB
testcase_30 AC 259 ms
6,940 KB
testcase_31 AC 200 ms
6,940 KB
testcase_32 AC 98 ms
6,940 KB
testcase_33 AC 81 ms
6,940 KB
testcase_34 AC 61 ms
6,940 KB
testcase_35 AC 107 ms
6,944 KB
testcase_36 AC 99 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 2 ms
6,944 KB
testcase_44 AC 3 ms
6,944 KB
testcase_45 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

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

  ll ans = LLONG_MAX;

  for (ll a = 0; a <= H; ++a) {
    if (a * KA >= H * W) {
      ans = min(ans, a);
    } else {
      ll ok = H * W;
      ll ng = 0;

      while (abs(ok - ng) >= 2) {
        ll x = (ok + ng) / 2;
        ll cnt = min(H, a * LA) * min(W, x * LB) + a * KA + x * KB;

        if (cnt >= H * W) {
          ok = x;
        } else {
          ng = x;
        }
      }

      ans = min(ans, a + ok);
    }
  }

  for (ll b = 0; b <= W; ++b) {
    if (b * KB >= H * W) {
      ans = min(ans, b);
    } else {
      ll ok = H * W;
      ll ng = 0;

      while (abs(ok - ng) >= 2) {
        ll x = (ok + ng) / 2;
        ll cnt = min(H, x * LA) * min(W, b * LB) + x * KA + b * KB;

        if (cnt >= H * W) {
          ok = x;
        } else {
          ng = x;
        }
      }

      ans = min(ans, b + ok);
    }
  }

  cout << ans << endl;

  return 0;
}
0