結果

問題 No.2227 King Kraken's Attack
ユーザー 👑 chro_96chro_96
提出日時 2023-04-08 00:57:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 457 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 10:13:38
合計ジャッジ時間 6,398 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 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 456 ms
6,944 KB
testcase_15 AC 442 ms
6,940 KB
testcase_16 AC 457 ms
6,940 KB
testcase_17 AC 205 ms
6,944 KB
testcase_18 AC 10 ms
6,940 KB
testcase_19 AC 440 ms
6,940 KB
testcase_20 AC 345 ms
6,940 KB
testcase_21 AC 338 ms
6,940 KB
testcase_22 AC 97 ms
6,944 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 200 ms
6,940 KB
testcase_25 AC 10 ms
6,944 KB
testcase_26 AC 441 ms
6,940 KB
testcase_27 AC 17 ms
6,940 KB
testcase_28 AC 237 ms
6,944 KB
testcase_29 AC 235 ms
6,944 KB
testcase_30 AC 241 ms
6,944 KB
testcase_31 AC 225 ms
6,940 KB
testcase_32 AC 102 ms
6,940 KB
testcase_33 AC 88 ms
6,940 KB
testcase_34 AC 65 ms
6,940 KB
testcase_35 AC 105 ms
6,940 KB
testcase_36 AC 126 ms
6,940 KB
testcase_37 AC 9 ms
6,944 KB
testcase_38 AC 3 ms
6,944 KB
testcase_39 AC 5 ms
6,940 KB
testcase_40 AC 9 ms
6,944 KB
testcase_41 AC 9 ms
6,944 KB
testcase_42 AC 5 ms
6,944 KB
testcase_43 AC 5 ms
6,940 KB
testcase_44 AC 8 ms
6,944 KB
testcase_45 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  long long h = 0LL;
  long long w = 0LL;
  long long la = 0LL;
  long long lb = 0LL;
  long long ka = 0LL;
  long long kb = 0LL;
  
  int res = 0;
  
  long long ans = 0LL;
  long long max = 0LL;
  
  res = scanf("%lld", &h);
  res = scanf("%lld", &w);
  res = scanf("%lld", &la);
  res = scanf("%lld", &lb);
  res = scanf("%lld", &ka);
  res = scanf("%lld", &kb);
  
  ans = h+w;
  max = h*w;
  if (kb > 0LL && max > 1LL+(h*w-1LL)/kb) {
    max = 1LL+(h*w-1LL)/kb;
  }
  
  for (long long a = 0LL; a <= h+w; a += 1LL) {
    long long tmp = 0LL;
    long long ar = la*a;
    long long b[2] = { -1LL, max };
    long long br = 0LL;
    if (ar > h) {
      ar = h;
    }
    while (b[1]-b[0] > 1LL) {
      long long nxt = (b[0]+b[1])/2LL;
      long long br = nxt*lb;
      if (br > w) {
        br = w;
      }
      if (h*w-ar*br > ka*a+kb*nxt) {
        b[0] = nxt;
      } else {
        b[1] = nxt;
      }
    }
    br = b[1]*lb;
    if (br > w) {
      br = w;
    }
    if (h*w-ar*br <= ka*a+kb*b[1] && a+b[1] < ans) {
      ans = a+b[1];
    }
  }
  
  printf("%lld\n", ans);
  return 0;
}
0