if(i==n-1) { if(sum/n <diff) { ans=i; } } else if(abs(w1/(i+1)-w2/(n-i-1)) < diff) { diff=abs(w1/(i+1)-w2/(n-i-1)); cout<<x; ans=i; }