結果

問題 No.2227 King Kraken's Attack
ユーザー 2bit
提出日時 2023-02-25 12:41:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 774 ms / 2,000 ms
コード長 1,927 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 195,228 KB
最終ジャッジ日時 2025-02-10 23:20:06
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

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++){
//0i使
__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++){
//0i使
__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();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0