Faucet Flow
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 276 | Accepted: 81 |
Description

Input
Each test case consists of two integers leftx (an odd number <= -1) and rightx (an odd number >= 1). Subsequent lines contain the height (a positive integer) of each divider from left to right. There will be no more than 1000 dividers in any test case. Input is terminated with a line containing two zeros.
Output
For each case, output an integer on a single line, indicating how long it will take, in seconds, before water starts spilling over either the left or right divider.
Sample Input
-1 13 5-3 34 3 2 1-3 51 2 2 1 10 0
Sample Output
668
Source
分析:逻辑问题。。。做两个阶梯,一个从左上升,一个从右上升,判断水龙头下方的那个区间哪个阶梯高,
1。一样高:选择小的那边乘二,再加上中间共有的那部分
2。右边高:找出最靠左边的比左边阶梯高的那个挡板,
第一个一样高的要特判并求那段水注满的时间,
之后类似情况一
3。同情况二