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. C++_系列自学课程_第_8_课_指针和引用_《C++ Primer 第四版》

    C语言最富有迷幻色彩的部分当属指针部分,无论是指针的定义还是指针的意义都可算是C语言中最复杂的内容.指针不但提供给了程序员直接操作硬件部分的操作接口,还提供给了程序员更多灵活的用法.C++继承这一高效 ...

  2. 更换Kali源让你更新更快

    在2016.1版本kali-linux(也就是kali滚动更新版)更新慢解决办法: (此源为2.0版本)中科大kali滚动更新版源(即kali2.0源) #kali官方源 deb http://htt ...

  3. swoole_redis 记一次看文档不仔细做警醒

    测试代码 $redisClass = new Redis(); $redisClass->connect('127.0.0.1', 6379, 1); $result = $redisClass ...

  4. PHP 命名空间(namespace)

    PHP 命名空间(namespace) PHP 命名空间(namespace)是在PHP 5.3中加入的,如果你学过C#和Java,那命名空间就不算什么新事物. 不过在PHP当中还是有着相当重要的意义 ...

  5. github指令

    一般用法 git stash git pull git stash pop 结局冲突 git add . git commit -m "message" git push 查看 g ...

  6. 第一个随笔,调试中,用的CSS3

    希望能在博客园很好的学习并得到技术上的提升!

  7. JavaScript toUpperCase() 方法和 toLowerCase() 方法

    1,toUpperCase() 方法用于把字符串转换为大写. 一个新的字符串,在其中 stringObject 的所有小写字符全部被转换为了大写字符. 语法为: stringObject.toUppe ...

  8. css判断不同分辨率显示不同宽度布局实现自适应宽度

    一.CSS DIV网页布局中当分辨率小于等于1024px(像素)时,DIV布局对象显示1000px宽度,当分辨率大于1024px时候显示1200px宽度等需求.使用CSS实现改变浏览器显示宽度从而实现 ...

  9. Linux学习心得之 Linux下ant安装与使用

    作者:枫雪庭 出处:http://www.cnblogs.com/FengXueTing-px/ 欢迎转载 Linux学习心得之 Linux下ant安装与使用 1. 前言2. ant安装3. 简单的a ...

  10. iOS之常用宏定义

    下面我为大家提供一些常用的宏定义! 将这些宏定义 加入到.pch使用 再也不用 用一次写一次这么长的程序了 //-------------------获取设备大小------------------- ...