Go to diff to previous submission
#include <stdio.h> /*#include <math.h>*/ double ah(double n) { return (n<0)?-n:n; } int main(){ int L,A,maxL,maxR,mid,mid2; double L2; int p,i; char c; /*struct { }Pole[100000];*/ L2=L/2.0; maxL=maxR=mid2=-1; if(c=='R') maxR=p; else maxL=p; mid=p; for(i=2;i<=A;++i){ if(c=='R'){ if(p<maxR) maxR=p; }else{ if(p>maxL) maxL=p; } if(ah(p-L2)<ah(mid-L2)){ mid=p; mid2=-1;} else if(ah(p-L2)==ah(mid-L2)) mid2=p; } //printf("%d%d%d\n",maxL,maxR,L); if(maxL==-1){ mid=maxR; }else if(maxR==-1){ mid=maxL; } maxL=(maxL>maxR)?maxL:(L-maxR); } return 0; }
--- c4.s1219.cteam125.ants.c.0.ant.c +++ c4.s1259.cteam125.ants.c.0.ant.c @@ -35,4 +35,9 @@ } //printf("%d%d%d\n",maxL,maxR,L); + if(maxL==-1){ + mid=maxR; + }else if(maxR==-1){ + mid=maxL; + } maxL=(maxL>maxR)?maxL:(L-maxR); printf("The last ant will fall down in %d seconds - started at %d",maxL,mid);