結果

問題 No.2227 King Kraken's Attack
ユーザー 👑 chro_96chro_96
提出日時 2023-02-24 22:18:41
言語 C
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,144 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 09:27:34
合計ジャッジ時間 2,612 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 <= 1LL+(h-1LL)/la; 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