最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
城固县| 鄂托克前旗| 抚宁县| 泸水县| 白水县| 沅陵县| 宁海县| 九龙坡区| 商洛市| 北碚区| 聂拉木县| 新竹县| 临武县| 通江县| 莎车县| 昌吉市| 玉树县| 静宁县| 吴旗县| 南溪县| 建始县| 敦化市| 盐源县| 大兴区| 雷州市| 大邑县| 开封县| 湟源县| 子长县| 曲水县| 金阳县| 彭泽县| 惠水县| 平原县| 石门县| 木兰县| 偃师市| 孝义市| 定日县| 仙游县| 万载县|