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>
typedef long long lld;
lld lh, s, d, l, b, d1, d2;
lld defeat(lld fhp, lld fhe, lld shp, lld she){
long long sum=0;
if(fhp<=lh && shp<=lh)return 1;
if(fhp > lh*2){
sum += (fhp-2*lh)/(2*lh-fhe), fhp -= sum*(2*lh-fhe), shp += sum*she;
}
if(fhp > lh*2){
fhp -= 2*lh-fhe, shp += she, sum++;
if(fhp <= lh)shp -= lh;
}
sum++, shp += she; // defeat first animal
if(shp > lh*2){
sum += (shp-2*lh)/(2*lh-she), shp = (shp-2*lh)%(2*lh-she)+2*lh;
}
if(shp > lh*2)sum+=2;
else sum++; // defeat second animal
return sum;
}
int main(){
scanf("%lld%lld%lld%lld%lld", &lh, &s, &d, &l, &b);
if(b > 0) return 0;
d1 = defeat(s, l, d, b);
d2 = defeat(d, b, s, l);
if(d1<d2)printf("%lld", d1);
else printf("%lld", d2);
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... |