結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
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 1 ms
6,940 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 2 ms
6,940 KB
testcase_14 AC 60 ms
6,940 KB
testcase_15 AC 60 ms
6,940 KB
testcase_16 AC 61 ms
6,940 KB
testcase_17 AC 96 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 59 ms
6,944 KB
testcase_20 AC 59 ms
6,940 KB
testcase_21 AC 60 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 52 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 61 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 61 ms
6,944 KB
testcase_29 AC 59 ms
6,940 KB
testcase_30 AC 60 ms
6,944 KB
testcase_31 AC 57 ms
6,940 KB
testcase_32 AC 45 ms
6,940 KB
testcase_33 AC 30 ms
6,940 KB
testcase_34 AC 17 ms
6,940 KB
testcase_35 AC 44 ms
6,944 KB
testcase_36 AC 22 ms
6,944 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 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = w + 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 (vp1 <= w) ? 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; 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