wuyuliang8
BAN USERif end with the first position:because average value is 1,the sum should be 1*1=1.but in fact the sum is 0,so the difference is 0-1=-1;
if end with the second position:because average value is 1,the sum should be 1*2=2.but in fact the sum is 0,so the difference is 0-2=-2;
if end with the third position:because average value is 1,the sum should be 1*3=3.but in fact the sum is 10,so the difference is 10-3=7;
firstly: calculate the average value to judge whether the result should be 0.
secondly: scan the array and calculate the difference if end with every position based on average value.
for example:0,0,10,0,0,0,0,0,0,0.the average value is 1,so the difference if end with every position is -1,-2,7,6,5,4,3,2,1,0.
finally: the result is the max absolute value of the difference.
The first question about this problem in my mind is that each server should share load with left, right, or both? I come up with the average value and the sum of previous, so that this question is solved.
- wuyuliang8 February 23, 2014Then I want to simulate each second,but it's too complex to realize it.At the same time,a sudden inspiration is coming and I test it.