結果

問題 No.2227 King Kraken's Attack
ユーザー tnakao0123tnakao0123
提出日時 2023-04-24 09:50:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,310 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 44,636 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 00:16:02
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2227.cc:  No.2227 King Kraken's Attack - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

ll check(int h, int w, int la, int lb, int ka, int kb, ll hp, ll vp) {
  ll dh = min(hp * la, (ll)h), dv = min(vp * lb, (ll)w);
  return min(hp * ka + vp * kb + dh * dv, (ll)h * w);
}

ll calcvp(int h, int w, int la, int lb, int ka, int kb, ll hp) {
  ll hw = (ll)h * w;
  ll vp0 = -1, vp1 = hw - hp;
  while (vp0 + 1 < vp1) {
    ll vp = (vp0 + vp1) / 2;
    if (check(h, w, la, lb, ka, kb, hp, vp) >= hw) vp1 = vp;
    else vp0 = vp;
  }
  return vp1;
}

/* subroutines */

/* main */

int main() {
  int h, w, la, lb, ka, kb;
  scanf("%d%d%d%d%d%d", &h, &w, &la, &lb, &ka, &kb);
  ll hw = (ll)h * w;

  ll hp0 = 0, hp1 = hw;
  while (hp0 + 2 < hp1) {
    ll hp00 = (hp0 * 2 + hp1) / 3;
    ll hp01 = (hp0 + hp1 * 2) / 3;
    ll s0 = calcvp(h, w, la, lb, ka, kb, hp00) + hp00;
    ll s1 = calcvp(h, w, la, lb, ka, kb, hp01) + hp01;
    if (s0 > s1) hp0 = hp00;
    else hp1 = hp01;
  }

  ll mins = LINF;
  for (ll hp = hp0; hp <= hp1; hp++)
    mins = min(mins, calcvp(h, w, la, lb, ka, kb, hp) + hp);

  printf("%lld\n", mins);
  return 0;
}
0