結果

問題 No.2227 King Kraken's Attack
ユーザー tnakao0123tnakao0123
提出日時 2023-04-24 10:27:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 44,252 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 00:48:59
合計ジャッジ時間 5,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 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 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,948 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 115 ms
6,940 KB
testcase_15 AC 143 ms
6,944 KB
testcase_16 AC 115 ms
6,940 KB
testcase_17 AC 150 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 122 ms
6,944 KB
testcase_20 AC 122 ms
6,944 KB
testcase_21 AC 136 ms
6,940 KB
testcase_22 AC 56 ms
6,940 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 75 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 129 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 124 ms
6,944 KB
testcase_29 AC 122 ms
6,940 KB
testcase_30 AC 160 ms
6,940 KB
testcase_31 AC 110 ms
6,944 KB
testcase_32 AC 59 ms
6,940 KB
testcase_33 AC 48 ms
6,940 KB
testcase_34 AC 36 ms
6,944 KB
testcase_35 AC 59 ms
6,940 KB
testcase_36 AC 60 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 int INF = 1 << 30;
const long long LINF = 1LL << 60;

/* typedef */

typedef long long ll;

/* global variables */

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

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

/* 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;

  int mins = INF;
  for (int hp = 0; hp <= h + w; hp++) {
    //printf("hp=%d, vp=%d\n", hp, calcvp(h, w, la, lb, ka, kb, hp));
    mins = min(mins, calcvp(h, w, la, lb, ka, kb, hp) + hp);
  }

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