#P1677. Hoofball Passing
Hoofball Passing
Hoofball Passing
Farmer John is preparing for the upcoming hoofball tournament by training his N cows (numbered 1 through \(N\), where \(1 \le N \le 100\)) for passing practice. The cows are positioned along a straight line on one side of the barn. The \(i\)th cow is located at position \(x_i\) (\(1 \le x_i \le 1000\)) and all positions are distinct.
At the start of the training, Farmer John can pass balls to a carefully chosen set of cows. When a cow receives a ball — whether directly from Farmer John or from another cow — she will pass the ball to the nearest cow. In the event of a tie (i.e. two cows are equally close), she will pass the ball to the cow that is further to the left (i.e. the one with the smaller coordinate).
Farmer John wants every cow to hold a ball at least once. Determine the minimum number of balls that he needs to pass initially to ensure this happens. You may assume that Farmer John can initially choose the most appropriate group of cows to pass the balls to.
The distance differences should be considered using the usual absolute difference, and any formulas should be represented in \(\LaTeX\) format.
inputFormat
The first line contains a single integer \(N\) \( (1 \le N \le 100)\), the number of cows. The second line contains \(N\) space-separated integers \(x_1, x_2, \dots, x_N\) \( (1 \le x_i \le 1000)\) representing the positions of the cows.
outputFormat
Output a single integer: the minimum number of balls Farmer John must initially pass so that every cow gets the ball at least once.
sample
4
1 2 5 6
2