#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ =1e5+100, inf = (ll)2e9 * (ll)2e9 + 7, mod = 998244353;
ll n, m, tc = 1, a, b, c, d, sum, x, y, z, base, ans, k;
ll gcd(ll x,ll y){
if(!y)return x;
return gcd(y,x%y);
}
//추가 일수 최소....
bool can;
ll get(ll dmg,ll hp,ll heal){
if(dmg>=hp){
if(dmg/2>=hp)can=true;
return 1;
}
if(dmg<=heal) return inf;
ll l=0,r=2e9,ret=inf;
while(l<=r){
ll mid=(l+r)/2;
if((dmg-heal)>=(hp-dmg)/mid){
ret=min(ret,mid);
r=mid-1;
}
else l=mid+1;
}
if(ret*(dmg-heal)>=hp-dmg/2)can=true;
return ret+1;
}
void solve(){
ll LH,S,D,L,B;
cin>>LH>>S>>D>>L>>B;
//if(D>=S)swap(S,D),swap(L,B);
//항상 S<=D임...
ans=inf;
can=false;
x=get(LH*2,S,L);
if(can){
if(D+(x-1)*B<=LH)ans=min(ans,x);
ans=min(ans,x+get(LH*2,D+x*B-LH,B));
}
else {
ans=min(ans,x+get(LH*2,D+x*B,B));
}
can=false;
x=get(LH*2,D,B);
if(can){
if(S+(x-1)*L<=LH)ans=min(ans,x);
ans=min(ans,x+get(LH*2,S+x*L-LH,L));
}
else ans=min(ans,x+get(LH*2,S+x*L,L));
cout<<ans<<endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
//cin >> tc;
while (tc--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |