結果

問題 No.2227 King Kraken's Attack
ユーザー 2bit2bit
提出日時 2023-02-25 12:17:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,740 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 197,460 KB
実行使用メモリ 13,764 KB
最終ジャッジ日時 2024-04-10 09:42:26
合計ジャッジ時間 5,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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];
  ll ok=H*W+1,ng=0; 
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    //mid回で条件を満たすことができるか
    ll now = -INF;
    for(ll i=0;i<=mid;i++){
      //0をi回使った場合
      ll w= min(i*L[1],H)*min((mid-i)*L[0],W);
      chmax(now,w+K[0]*i+K[1]*(mid-i));
    }
    for(ll i=0;i<=mid;i++){
      //0をi回使った場合
      ll h= min((mid-i)*L[1],H)*min(i*L[0],W);
      chmax(now,h+K[0]*(mid-i)+K[1]*i);
    }
    if(now>=H*W)ok=mid;
    else ng = mid;
  }
  cout<<ok<<endl;
}
int main(){
  fast_io();
  int num_tc = 1;
  //cin >> num_tc;
  rep(tc,num_tc){
    //cout << "Case #" << tc+1 << ": " ;// << endl;
    solve();
  }
}
0