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-1)/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; }