无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 474A - Keyboard

2023-08-22 14:57 作者:您是打尖兒還是住店呢  | 我要投稿

Mike is trying rock climbing but he is awful at it.


There are n holds on the wall, i-th hold is at height ai off the ground. Besides, let the sequence ai increase, that is, ai?<?ai?+?1 for all i from 1 to n?-?1; we will call such sequence a track. Mike thinks that the track a1, ..., an has difficulty . In other words, difficulty equals the maximum distance between two holds that are adjacent in height.


Today Mike decided to cover the track with holds hanging on heights a1, ..., an. To make the problem harder, Mike decided to remove one hold, that is, remove one element of the sequence (for example, if we take the sequence (1,?2,?3,?4,?5) and remove the third element from it, we obtain the sequence (1,?2,?4,?5)). However, as Mike is awful at climbing, he wants the final difficulty (i.e. the maximum difference of heights between adjacent holds after removing the hold) to be as small as possible among all possible options of removing a hold. The first and last holds must stay at their positions.


Help Mike determine the minimum difficulty of the track after removing one hold.


Input

The first line contains a single integer n (3?≤?n?≤?100) — the number of holds.


The next line contains n space-separated integers ai (1?≤?ai?≤?1000), where ai is the height where the hold number i hangs. The sequence ai is increasing (i.e. each element except for the first one is strictly larger than the previous one).


Output

Print a single number — the minimum difficulty of the track after removing a single hold.

-----------------------------------------

邁克正在嘗試攀巖,但他的表現(xiàn)很糟糕。


墻上有 n 個據(jù)點,第 i 個據(jù)點位于距地面高度 ai 處。 另外,讓序列ai遞增,即對于所有i從1到n?-?1,ai?<?ai?+?1; 我們將這樣的序列稱為軌道。 Mike 認(rèn)為軌道 a1, ..., an 有困難。 換句話說,難度等于高度相鄰的兩個點之間的最大距離。


今天,邁克決定用懸掛在高度 a1, ..., an 上的支撐點覆蓋賽道。 為了使問題變得更難,Mike 決定刪除一個保留,即刪除序列中的一個元素(例如,如果我們采用序列 (1,?2,?3,?4,?5) 并從中刪除第三個元素, 我們得到序列 (1,?2,?4,?5))。 然而,由于 Mike 的攀爬能力很差,他希望在所有可能的移除抓點的選項中,最終的難度(即移除抓點后相鄰抓點之間的最大高度差)盡可能小。 第一個和最后一個保持點必須保持在原來的位置。


幫助邁克確定取消一個握點后賽道的最低難度。


輸入

第一行包含一個整數(shù) n (3?≤?n?≤?100) — 保持的數(shù)量。


下一行包含 n 個空格分隔的整數(shù) ai (1?≤?ai?≤?1000),其中 ai 是保持編號 i 懸掛的高度。 序列 ai 正在增加(即除了第一個元素之外的每個元素都嚴(yán)格大于前一個元素)。


輸出

打印一個數(shù)字——移除單個支撐后賽道的最低難度。

---------------------------------------------

每次保存2個變量,然后根據(jù)變量去處理即可。

CF 474A - Keyboard的評論 (共 條)

分享到微博請遵守國家法律
和平县| 德昌县| 霍城县| 双桥区| 郎溪县| 林甸县| 邢台市| 武山县| 项城市| 嘉定区| 桦南县| 疏勒县| 桑植县| 霍林郭勒市| 罗甸县| 永仁县| 东源县| 金秀| 滨州市| 册亨县| 内江市| 松潘县| 寻乌县| 太仓市| 肃宁县| 文安县| 遵义市| 湄潭县| 黄大仙区| 康保县| 平凉市| 浦江县| 东至县| 天全县| 舞阳县| 镇平县| 东丰县| 维西| 绩溪县| 阳谷县| 桃园市|