This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> Pi;
ll solve(ll lh, ll s, ll d, ll l, ll b)
{
ll ans = 0;
if(s <= lh)ans = 1, d -= lh;
else if(s <= 2*lh)ans = 1;
else{
s -= 2*lh;
ans = 1;
ll A = 2*lh - l;
ll D = (s+A-1) / A;
ans += D;
s -= D * A;
if(s+lh <= 0)d -= lh;
}
if(d <= 0)return ans;
d += ans * b;
if(d <= 2*lh)return ans+1;
else{
d -= 2*lh;
ans++;
ll A = 2*lh - b;
ans += (d+A-1) / A;
}
return ans;
}
int main()
{
ll lh, s, d, l, b;
scanf("%lld%lld%lld%lld%lld",&lh,&s,&d,&l,&b);
printf("%lld", min(solve(lh, s, d, l, b), solve(lh, d, s, b, l)));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |