제출 #6358

#제출 시각아이디문제언어결과실행 시간메모리
6358Namnamseo쌍둥이 독수리 (GA7_twineagles)C++98
11 / 100
0 ms1672 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...