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>
long long day(long long e, long long d, long long s)
{
if (e <= s) return 1;
return (e - d - 1) / (s - d) + 1;
}
long long min(long long a, long long b)
{
return a < b ? a : b;
}
int main()
{
long long s,e[2],d[2];
scanf ("%lld %lld %lld %lld %lld",&s,e,e+1,d,d+1);
long long ans = 1ll<<62;
for (int k=0;k<2;k++){
long long a = day(e[k],d[k],s*2) - 1;
if (e[k] + (d[k] - s * 2) * a <= s){
if (e[!k] + d[!k] * a <= s) a++;
else a += day(e[!k]+d[!k]*a-s,d[!k],s*2) + 1;
}
else a += day(e[!k]+d[!k]*a,d[!k],s*2);
ans = min(ans,a);
}
printf ("%lld\n",ans);
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... |