Hi
I’m new to code chef recently joined.
I’m trying to solve the elevator problem .Howeve rwhen I submit I keep getting wrong answer error.
Please help!! here’s my code:
int main(){
int distance = 0, vel1 = 0, vel2 = 0;
float time1 = 0 ,time2 =0;
//Enter Distance, velocity of elevator and stairs
scanf("%d %d %d",&distance,&vel1,&vel2);
/*if vel1>vel2 i.e velocity of stairs > velocity of Elevator
automatically display stairs since 1.41*Distance < 2*Distance*/
if(vel1 >= vel2){
printf("Stairs");
return(0);
}
time1 = (sqrt(2) * distance)/ (float) vel1;
time2 = (2*distance)/(float) vel2; //convert to float
//Check for least time
if(time1 <time2)
printf("Stairs");
else
printf("Elevator");
return(0);
}