CF5E--Bindian Signalizing翻译

原题链接--

https://acs.jxnu.edu.cn/problem/CF5Eicon-default.png?t=M0H8https://acs.jxnu.edu.cn/problem/CF5E 

Bindian Signalizing

 4000ms  262144K

描述:

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.

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.

译文:所有人都知道在很久以前伯兰的领土上生活着印第安部落。他们的首都被n座山围绕,形成了一个圈。在每座山上有个看守者,日夜看守着周围的地方。

为了防止看守者在山上生火造成危险.如果在连接两座山的圆弧上,没有比这两座山更高的山,那么一个看守者能看见另一个看守者。任意两座山有两个不同的圆弧相连,如果任意一个圆弧满足以上条件那么信号能被看见。举个例子,任意两个相邻的看守者之间的信号都能被互相看到。

一个重要的特征对于看守系统就是看守者之间能互相看到信号的对数。你应该通过所给山之间的高度来找到这个数量。

输入:

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值