02.10 Bindian Signalizing Bindian标志

Bindian Signalizing | JXNUOJ

描述:

Everyone knows that long ago on the territory of present-day Berland there lived Bindian tribes. Their capital was surrounded by n hills, forming a circle. On each hill there was a watchman, who watched the neighbourhood day and night.

众所周知,在很久以前,今天Berland的领地上有Bindian部落。他们的首都被n座小山包围,形成一个圈。在每个小山上都有一个守望者,日夜监视着邻村。

In case of any danger the watchman could make a fire on the hill. One watchman could see the signal of another watchman, if on the circle arc connecting the two hills there was no hill higher than any of the two. As for any two hills there are two different circle arcs connecting them, the signal was seen if the above mentioned condition was satisfied on at least one of the arcs. For example, for any two neighbouring watchmen it is true that the signal of one will be seen by the other.

如果发生任何危险,守望者可以在山上点火。一个守望者可以看见另一个守望者的信号,如果在链接两座小山的中间的圆弧不比任何一个小山要高。在任何两座小山中间都有两个不同的圆弧链接他们,信号就会被看到如果其中一个圆弧能满足上述条件。例如,任何两个相邻的守望者能够看见另一个信号。

An important characteristics of this watch system was the amount of pairs of watchmen able to see each other's signals. You are to find this amount by the given heights of the hills.

该守望系统一个最重要的因素就是能够看到彼此信号的成对的守望者。你将通过给定的小山高度找到此数量。

输入:

The first line of the input data contains an integer number n (3 ≤ n ≤ 106), n — the amount of hills around the capital. The second line contains n numbers — heights of the hills in clockwise order. All height numbers are integer and lie between 1 and 109.

第一行的输入包含一个整数n(3 ≤ n ≤ 106), n — 首都周围的小山的数量。第二行包含n个数据——按顺时针排列的小山的高度。所有高度数据都是整数且处于1到109之间。

输出:

Print the required amount of pairs.

输出对数。

样例输入:

5
1 2 4 5 3

样例输出:

7
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值