結果

問題 No.2227 King Kraken's Attack
ユーザー 2bit2bit
提出日時 2023-02-25 12:41:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 633 ms / 2,000 ms
コード長 1,927 bytes
コンパイル時間 3,297 ms
コンパイル使用メモリ 198,312 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 09:43:57
合計ジャッジ時間 12,500 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 630 ms
6,940 KB
testcase_15 AC 622 ms
6,940 KB
testcase_16 AC 622 ms
6,940 KB
testcase_17 AC 590 ms
6,940 KB
testcase_18 AC 357 ms
6,940 KB
testcase_19 AC 358 ms
6,944 KB
testcase_20 AC 360 ms
6,940 KB
testcase_21 AC 425 ms
6,940 KB
testcase_22 AC 63 ms
6,940 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 232 ms
6,940 KB
testcase_25 AC 356 ms
6,944 KB
testcase_26 AC 633 ms
6,944 KB
testcase_27 AC 356 ms
6,944 KB
testcase_28 AC 368 ms
6,944 KB
testcase_29 AC 360 ms
6,940 KB
testcase_30 AC 482 ms
6,940 KB
testcase_31 AC 329 ms
6,940 KB
testcase_32 AC 155 ms
6,940 KB
testcase_33 AC 133 ms
6,940 KB
testcase_34 AC 99 ms
6,940 KB
testcase_35 AC 169 ms
6,944 KB
testcase_36 AC 169 ms
6,940 KB
testcase_37 AC 121 ms
6,944 KB
testcase_38 AC 82 ms
6,940 KB
testcase_39 AC 64 ms
6,940 KB
testcase_40 AC 79 ms
6,944 KB
testcase_41 AC 288 ms
6,940 KB
testcase_42 AC 70 ms
6,940 KB
testcase_43 AC 139 ms
6,944 KB
testcase_44 AC 258 ms
6,940 KB
testcase_45 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define fix(x) fixed << setprecision(x)
#define eb emplace_back
constexpr char nl='\n';
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vs = vector<string>;
using pl = pair<long long, long long>;
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}
template<class T>using rp_queue=priority_queue<T,vector<T>,greater<T>>;
void fast_io(){cin.tie(nullptr);ios_base::sync_with_stdio(false);}
template <typename T> T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);}
template <typename T> inline T lcm(T a, T b) {return a /gcd(a, b)*b;}
const ll INF = 1LL << 60;
const ld PI = acos(-1);
void solve(){
  ll H,W;cin>>H>>W;
  vl L(2),K(2);
  rep(i,2)cin>>L[i];
  rep(i,2)cin>>K[i];
  __int128 ok=H*W*10,ng=0; 
  //O((H+W)log(HW))
  while(ok-ng>1){
    __int128 mid=(ok+ng)/2;
    //mid回で条件を満たすことができるか
    __int128 now = 0LL;
    for(ll i=0;i<=min<__int128>(mid,H);i++){
      //0をi回使った場合
      __int128 h = min<__int128>(i*L[0],H);
      __int128 w = min<__int128>((mid-i)*L[1],W);
      chmax<__int128>(now,h*w+K[0]*i+K[1]*(mid-i));
    }
    for(ll i=0;i<=min<__int128>(mid,W);i++){
      //0をi回使った場合
      __int128 h = min<__int128>((mid-i)*L[0],H);
      __int128 w = min<__int128>(i*L[1],W);
      chmax<__int128>(now,h*w+K[0]*(mid-i)+K[1]*i);
    }
    if(now>=H*W)ok=mid;
    else ng=mid;
  }
  cout<<(ll)ok<<endl;
}
int main(){
  fast_io();
  int num_tc = 1;
  //cin >> num_tc;
  rep(tc,num_tc){
    //cout << "Case #" << tc+1 << ": " ;// << endl;
    solve();
  }
}
0