2022.02.04翻译Bindian Signalizing

Bindian Signalizing
题目(https://acs.jxnu.edu.cn/problem/CF5E)描述:
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.

输入:
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.

输出:
Print the required amount of pairs.

样例输入:
5
1 2 4 5 3
样例输出:
7

翻译:
大家知道很久以前,在波兰的现在的领土上住着Bindian部落的人。他们的首都被n个山丘环绕,形成一个环形。在每个山丘上都一个观察的人,日夜守护这里的部落。

如果他们发现危险,他们会在山丘上点火。如果在环形弧上的另一个山丘与点火山丘间没有比这两个山丘高的山丘,点火的信号就可以被另一个山丘的观察者看到。因为任意两个在环形上的山丘间有两条不同的弧,如果有一条弧满足上述条件,另一个山丘上的观察者就能看到信号。

这个系统的一个重要的性质就是互相能够看到信号的观察者的对数。给出山丘的高度,求出对数。

输入:
第一行输入一个整数n (3 ≤ n ≤ 106),表示山丘的个数。第二行包含n个数字,表示对应顺序的山丘的高度,高度都是在1到109间的整数。

输出:
能够相互看到信号的观察者的对数。

样例输入:
5
1 2 4 5 3
样例输出:
7

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值