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 <iostream>
long long max(long long a,long long b) {return (a>b)?a:b;}
long long min(long long a,long long b) {return (a>b)?b:a;}
long long attackTime(long long attack,long long hp,long long heal) {
long long ret = (hp - heal) / (attack - heal);
if((hp - heal) % (attack - heal)) ret++;
return ret;
}
int main()
{
long long attack,
hpLion,healLion,
hpBear,healBear,
t1,t2, mintime = (1LL<<60), temp, temp2, temp3;
std::cin>>attack>>hpLion>>hpBear>>healLion>>healBear;
/// case 1 : attack lion first
for(int i=0;i<2;i++){
t1 = attackTime(2*attack,hpLion,healLion);
temp = hpBear + healBear*t1;
if(hpLion + (t1-1)*(healLion - 2*attack) <= attack) {
temp -= attack;
}
t2 = attackTime(2*attack,temp,healBear);
mintime = min (mintime, t1+t2);
temp = hpLion;
hpLion = hpBear;
hpBear = temp;
temp = healLion;
healLion = healBear;
healBear = temp;
}
/// case 2 : attack both
t1 = attackTime(attack,hpLion,healLion);
t2 = attackTime(attack,hpBear,healBear);
if(t1 < t2) {
temp = hpBear+t1*(healBear-attack);
temp2 = t1 + attackTime(2*attack,temp,healBear);
mintime = min(mintime,min(temp2,max(t1,t2)));
} else if(t1>t2){
temp = hpLion+t2*(healLion-attack);
temp2 = t2 + attackTime(2*attack,temp,healLion);
mintime = min(mintime,min(temp2,max(t1,t2)));
}
std::cout<<mintime<<std::endl;
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... |