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

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

分享到微博請遵守國家法律
绥中县| 恭城| 改则县| 建阳市| 贵溪市| 铜川市| 施甸县| 钟山县| 安吉县| 新密市| 重庆市| 韩城市| 秦安县| 琼中| 黄山市| 武鸣县| 基隆市| 昌吉市| 怀远县| 定兴县| 阜平县| 沁源县| 宝坻区| 威信县| 洞头县| 栖霞市| 丰镇市| 右玉县| 裕民县| 内江市| 凤阳县| 黔西| 台东市| 新昌县| 沙坪坝区| 成安县| 玉环县| 紫金县| 尚志市| 武宁县| 广州市|