結果

問題 No.2227 King Kraken's Attack
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-07-14 04:17:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 691 bytes
コンパイル時間 3,059 ms
コンパイル使用メモリ 243,028 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 12:35:50
合計ジャッジ時間 9,473 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 32 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define db double
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
	ll h,w,ah,aw,bh,bw;cin>>h>>w>>ah>>aw>>bh>>bw;
	ll ans=h+w;
	for(ll i=0;i<h+w;i++){
		ll x=min(h,i*ah);
		ll r=h*w-i*bh;
		if(r<=0){
			ans=min(ans,i);
			continue;
		}
		ll wa=0,ac=(r+bw-1)/bw;
		while(ac-wa>1){
			ll m=(ac+wa)/2;
			ll now=min(w,aw*m)*x+m*bw;
			if(now>=r)ac=m;
			else wa=m;
		}
		ans=min(ans,ac+i);
	}
	cout<<ans;
}
0