Flooded!
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 5955   Accepted: 1800   Special Judge

Description

To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provides clients with the elevation of each 10-meter by 10-meter square of land in regions where homes may be purchased. Water from rain, melting snow, and burst water mains will collect first in those squares with the lowest elevations, since water from squares of higher elevation will run downhill. For simplicity, we also assume that storm sewers enable water from high-elevation squares in valleys (completely enclosed by still higher elevation squares) to drain to lower elevation squares, and that water will not be absorbed by the land. 
From weather data archives, we know the typical volume of water that collects in a region. As prospective homebuyers, we wish to know the elevation of the water after it has collected in low-lying squares, and also the percentage of the region's area that is completely submerged (that is, the percentage of 10-meter squares whose elevation is strictly less than the water level). You are to write the program that provides these results. 

Input

The input consists of a sequence of region descriptions. Each begins with a pair of integers, m and n, each less than 30, giving the dimensions of the rectangular region in 10-meter units. Immediately following are m lines of n integers giving the elevations of the squares in row-major order. Elevations are given in meters, with positive and negative numbers representing elevations above and below sea level, respectively. The final value in each region description is an integer that indicates the number of cubic meters of water that will collect in the region. A pair of zeroes follows the description of the last region.

Output

For each region, display the region number (1, 2, ...), the water level (in meters above or below sea level) and the percentage of the region's area under water, each on a separate line. The water level and percentage of the region's area under water are to be displayed accurate to two fractional digits. Follow the output for each region with a blank line.

Sample Input

3 3
25 37 45
51 12 34
94 83 27
10000
0 0

Sample Output

Region 1
Water level is 46.67 meters.
66.67 percent of the region is under water.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<fstream>
using namespace std;
#define LEN 1000 int main (void)
{
int n,m,start,maxn,num,sum,i;
int region[LEN];
double water,remain;
num=;
while(cin>>n>>m&&(n||m)){
for(i=;i<n*m;i++)
cin>>region[i];
cin>>maxn;
sort(region,region+n*m);
start=region[];
sum=;
for(i=;i<n*m;i++)
if(sum+(region[i]-start)*i*<=maxn){
sum+=(region[i]-start)*i*;
start=region[i];
}
else
break;
remain=maxn-sum;
water=region[i-]+remain/(double(i)*100.0);
for(i=;region[i]<water&&i<n*m;i++);
printf("Region %d\n",num++);
printf("Water level is %.2f meters.\n",water);
printf("%.2f percent of the region is under water.\n\n",*i/double(n*m));
}
return ;
}

Flooded!的更多相关文章

  1. [刷题]算法竞赛入门经典(第2版) 4-10/UVa815 - Flooded!

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa815 - Flooded! #include<iostream ...

  2. uvA Flooded!

    Description To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provide ...

  3. UVA 815 Flooded!

    题意:来自:https://blog.csdn.net/lecholin/article/details/70186673 思路: ①数组存每个网格的高度,然后排序,做题时想象为上面的柱状图. ②注意 ...

  4. 【每日一题】Flooded! UVA - 815 模拟阅读格式题

    https://cn.vjudge.net/problem/UVA-815 题意:给你一个矩阵,每个格子的数代表一个海拔并且每个格子的面积100平方米.给你整个区域的降水量(立方米),问降水量(米). ...

  5. 洪水!(Flooded! ACM/ICPC World Final 1999,UVa815)

    题目描述:竞赛入门经典的习题4-10 解题思路:1.把各个网格想象成一个数组 2.排序 3.雨水总体积去铺满 //太懒了只写了求海拔 #include <stdio.h> #define ...

  6. 【习题 4-9 UVA - 815】Flooded!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 题目很迷啊. 不会出现盆地? 可以理解为一条线. 从左往右高度上升的一座座山. 然后V升的水从最左边的山倒进去. 然后问你最后海拔多 ...

  7. Flooded! UVA - 815 (sort排序)

    错了好多遍,不知道为啥出错,如果有大神发现,请求指点!!! 附错误代码(错的不知道怎么回事): #include<iostream> #include<cstdio> #inc ...

  8. zoj 3859 DoIt is Being Flooded (MFSet && Flood Fill)

    ZOJ :: Problems :: Show Problem 这题开始的时候想不到怎么调整每个grid的实际淹没时间,于是只好找了下watashi的题解,发现这个操作还是挺简单的. ZOJ3354 ...

  9. Linux中SysRq的使用(魔术键)

    转:http://www.chinaunix.net/old_jh/4/902287.html 魔术键:Linux Magic System Request Key Hacks 当Linux 系统不能 ...

随机推荐

  1. 【nodejs笔记3】Express基本用法,和路由控制,和模板渲染ejs

    1. 路由控制的工作原理 //routes/index.js中的代码//访问主页时,调用ejs模板引擎,渲染index.ejs模板文件,生成静态页面,并显示在浏览器中.router.get('/', ...

  2. 第一个web框架tornado

    简介 tornado,是我学到的第一个web框架是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像web.py 或者 Google ...

  3. Java Web中乱码问题

    response.setContentType("text/html;charset=UTF-8"); 用于定义网络文件的类型和网页的编码,决定浏览器将以什么形式.什么编码读取这个 ...

  4. iOS 系统根据导航栏和状态栏自动修改布局

    问题 条件:1.有一个全屏大小的带导航的controller 2.隐藏导航栏,最顶上还会留出状态栏的位置,而不是全屏显示 解决方法 self.automaticallyAdjustsScrollVie ...

  5. css解决方案

    1,Flexbox(更优雅的布局) ①居中:{display:flex; justify-content:center; align-items:center;}②设定flex-grow属性的话,会自 ...

  6. [Erlang 0108] Elixir 入门

    Erlang Resources里面关于Elixir的资料越来越多,加上Joe Armstrong的这篇文章,对Elixir的兴趣也越来越浓厚,投入零散时间学习了一下.零零散散,测试代码写了一些,Ev ...

  7. 有氧运动 && 无氧运动

    有氧运动也叫做有氧代谢运动,是指人体在氧气充分供应的情况下进行的体育锻炼.有氧运动的好处是:可以提升氧气的摄取量,能更好地消耗体内多余的热量.也就是说,在运动过程中,人体吸入的氧气与需求相等,达到生理 ...

  8. C#知识点整理

    1.我们在Main()函数中,调用Test()函数,我们管Main()函数称之为调用者, 管Test()函数称之为被调用者. 如果被调用者想要得到调用者的值: 1).传递参数. 2).使用静态字段来模 ...

  9. Linux脚本学习

    1.脚本 linux下创建一个以.sh为后缀名的文件,然后更改权限为可执行,这就变成了一个脚本文件 touch test.sh chmod u+x test.sh 脚本的最简单使用方式,就是批量命令的 ...

  10. Terminate Instance 操作详解 - 每天5分钟玩转 OpenStack(33)

    本节通过日志详细分析 Nova Terminate 操作. Terminate 操作就是删除 instance,下面是 terminate instance 的流程图 向 nova-api 发送请求 ...