ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1602. Elevator

WA #4
Posted by kobra 21 Jun 2008 20:12
#include <stdio.h>

int main()
{
    int i,n,k,best;
    float timeu,timev,time,v,u,A[101],besttime;
    scanf("%d%d%f%f",&n,&k,&u,&v);
    for(i=n;i>=1;i--)
    {
        timeu=(n-i)*u;
        timev=(k-1)*v;
        if(timeu<timev+15)
            time=timev+15+2*(i-1)*v+5;
        else if(timeu-timev>15)
            time=timeu+2*(i-1)*v+5;
        else time=timev+(timev-timeu)+2*(i-1)*v+5;
        A[i]=time;
    }
    besttime=A[n];
    best=n;
    for(i=n-1;i>0;i--)
        if(besttime-A[i]>0.00000000001) {
            besttime=A[i];
            best=i;
        }
    printf("%d",best);
    return 0;
}
Who can give me some tests? i dont know what is incorrect
Re: WA #4
Posted by Niyaz Nigmatullin {Litsey #2, Kazan} 1 Jun 2009 11:56
I passed this test, when I understood that, if he has to go to the first floor using his legs, he mustn't enter the elevator. So, when calculating time, when he goes to the first floor, you shouldn't add 5 seconds to the time.