A772.Hoofball--Bronze

普及-

USACO

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

In preparation for the upcoming hoofball tournament, Farmer John is drilling
his NN cows (conveniently numbered 1…N1\dots N) in
passing the ball. The cows are all standing along a very long line on one side
of the barn, with cow ii standing xix_i units away from the barn . Each cow is standing at a distinct location.
At the beginning of the drill, Farmer John will pass several balls to
different cows. When cow ii receives a ball, either from Farmer John or from
another cow, she will pass the ball to the cow nearest her (and if multiple
cows are the same distance from her, she will pass the ball to the cow
farthest to the left among these). So that all cows get at least a little bit
of practice passing, Farmer John wants to make sure that every cow will hold a
ball at least once. Help him figure out the minimum number of balls he needs
to distribute initially to ensure this can happen, assuming he hands the balls
to an appropriate initial set of cows.

输入格式

The first line contains NN, the number of cows. The second line contains NN space-separated integers, where the iith integer is xix_i, the distance of cow ii from the barn.

输出格式

Please output the minimum number of balls Farmer John must initially pass to
the cows, so that every cow can hold a ball at least once.

输入输出样例

  • 输入#1

    5
    7 1 3 11 4
    

    输出#1

    2
    

说明/提示

数据范围:1≤N≤1001 \le N \le 100,1≤xi≤10001 \le x_i \le 1000,且所有 xix_i 互不相同。

输入解题思路,AI测评打分。不知道怎么写?

首页