Submission #6358

# Submission time Handle Problem Language Result Execution time Memory
6358 2014-06-28T12:55:06 Z Namnamseo 쌍둥이 독수리 (GA7_twineagles) C++
11 / 100
0 ms 1672 KB
#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
1 Correct 0 ms 1672 KB Output is correct
2 Correct 0 ms 1672 KB Output is correct
3 Correct 0 ms 1672 KB Output is correct
4 Correct 0 ms 1672 KB Output is correct
5 Correct 0 ms 1672 KB Output is correct
6 Correct 0 ms 1672 KB Output is correct
7 Correct 0 ms 1672 KB Output is correct
8 Correct 0 ms 1672 KB Output is correct
9 Correct 0 ms 1672 KB Output is correct
10 Correct 0 ms 1672 KB Output is correct
11 Correct 0 ms 1672 KB Output is correct
12 Correct 0 ms 1672 KB Output is correct
13 Correct 0 ms 1672 KB Output is correct
14 Correct 0 ms 1672 KB Output is correct
15 Correct 0 ms 1672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1672 KB Output is correct
2 Incorrect 0 ms 1672 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -