|
|
back to boardWA #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 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. |
|
|