当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2452:Sticks Problem

题目描述
Xuanxuan has n sticks of different length. One day, she puts all her sticks in a line, represented by S1, S2, S3, ...Sn. After measuring the length of each stick Sk (1 <= k <= n), she finds that for some sticks Si and Sj (1<= i < j <= n), each stick placed between Si and Sj is longer than Si but shorter than Sj.

Now given the length of S1, S2, S3, …Sn, you are required to find the maximum value j - i.
输入解释
The input contains multiple test cases. Each case contains two lines.
Line 1: a single integer n (n <= 50000), indicating the number of sticks.
Line 2: n different positive integers (not larger than 100000), indicating the length of each stick in order.
输出解释
Output the maximum value j - i in a single line. If there is no such i and j, just output -1.
输入样例
4
5 4 3 6
4
6 5 4 3
输出样例
1
-1

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 POJ Monthly,static

源链接: POJ-2452

最后修改于 2020-10-29T06:32:52+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000 65536