Problem 1907 --Problem E: Faucet Flow

1907: Problem E: Faucet Flow

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $31$ 正确数量 $13$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

Problem E: Faucet Flow

A faucet is pouring water into a long, thin aquarium with various vertical dividers (walls) in it. The aquarium is initially empty, and its bottom is perfectly level. How long will it take for water to spill over its left- or right-most divider? The faucet is above location x=0, and the dividers are located at x=-1, -3, -5, ..., leftx and 1, 3, 5, ..., rightx. The dividers are attached perpendicular to the floor and sides of the aquarium, and have various heights. The aquarium's length is greater than rightx-leftx, its walls are higher than the highest divider, and its width is 1 unit everywhere. Water pours from the faucet at a rate of 1 cubic unit per second. [You may assume that water is an ideal liquid: it always flows downhill and if it cannot flow downhill it spreads at an equal rate in all horizontal directions.]

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.

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.

-1 1
3 5
-3 3
4 3 2 1
-3 5
1 2 2 1 1
0 0
6
6
8

推荐代码 查看1907 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$4 $ms] AOJ大管家 84422 2017-04-27 15:28:57
内存最少[$992 $KB] AOJ大管家 84422 2017-04-27 15:28:57
第一AC AOJ大管家 84422 2017-04-27 15:28:57
第一挑战 AOJ大管家 84422 2017-04-27 15:28:57

赛题来源/所属竞赛 NA N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛
1085 2016-2017-2学期《JavaWeb系统开发》课程测试(14CS12,14NE12,14IS12) 2017-05-19 14:00:00 请登录