Flooded!
Time Limit: 1000MS | Memory Limit: 30000K | |||
Total Submissions: 5955 | Accepted: 1800 | Special Judge |
Description
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
Output
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!的更多相关文章
- [刷题]算法竞赛入门经典(第2版) 4-10/UVa815 - Flooded!
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa815 - Flooded! #include<iostream ...
- uvA Flooded!
Description To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provide ...
- UVA 815 Flooded!
题意:来自:https://blog.csdn.net/lecholin/article/details/70186673 思路: ①数组存每个网格的高度,然后排序,做题时想象为上面的柱状图. ②注意 ...
- 【每日一题】Flooded! UVA - 815 模拟阅读格式题
https://cn.vjudge.net/problem/UVA-815 题意:给你一个矩阵,每个格子的数代表一个海拔并且每个格子的面积100平方米.给你整个区域的降水量(立方米),问降水量(米). ...
- 洪水!(Flooded! ACM/ICPC World Final 1999,UVa815)
题目描述:竞赛入门经典的习题4-10 解题思路:1.把各个网格想象成一个数组 2.排序 3.雨水总体积去铺满 //太懒了只写了求海拔 #include <stdio.h> #define ...
- 【习题 4-9 UVA - 815】Flooded!
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 题目很迷啊. 不会出现盆地? 可以理解为一条线. 从左往右高度上升的一座座山. 然后V升的水从最左边的山倒进去. 然后问你最后海拔多 ...
- Flooded! UVA - 815 (sort排序)
错了好多遍,不知道为啥出错,如果有大神发现,请求指点!!! 附错误代码(错的不知道怎么回事): #include<iostream> #include<cstdio> #inc ...
- zoj 3859 DoIt is Being Flooded (MFSet && Flood Fill)
ZOJ :: Problems :: Show Problem 这题开始的时候想不到怎么调整每个grid的实际淹没时间,于是只好找了下watashi的题解,发现这个操作还是挺简单的. ZOJ3354 ...
- Linux中SysRq的使用(魔术键)
转:http://www.chinaunix.net/old_jh/4/902287.html 魔术键:Linux Magic System Request Key Hacks 当Linux 系统不能 ...
随机推荐
- HTML5标签与HTML4标签的区别示例介绍_html5教程技巧
(1)概念的变化: HTML5专注内容与结构,而不专注的表现 <header> <hgroup>导航相关数据</hgroup> </header> &l ...
- Java中, 函数的调用、随机数字
函数: 独立完成某个功能的代码模块.(方法) 作用是为了让代码结构更加良好.模块清晰,实现重用. 函数的四要素:名称,输入值,加工过程,返回值 Java中函数的语法 static 返回类型 函 ...
- Java--JDK动态代理核心源码解析
1.首先我们了解一下JDK动态代理的使用方法: public static void main(String[] args) { /** * 创建一个Bean对象,该对象实现BeanInterFace ...
- MySQL字符串替换与HTML转义
ps:今天遇到一个问题,从数据库读取一个字符串,然后在jsp用EL表达式显示时,因为数据库原始数据是带有HTML标签的,所以显示的时候会把标签直接转换成HTML,但是我想要的是HTML标签字符串,所以 ...
- javascript中的弹框
大家都见过某度中的恶意广告,你关闭了又出来了!为何,JS来告诉你 效果猛戳此处 HTML <body> <h3 class="whiteColor">无法关 ...
- Java Web中请求转发和请求包含
1.都是在一个请求中跨越多个Servlet 2.多个Servlet在一个请求中,他们共享request对象.就是在AServle中setAttribute()保存数据在BServlet中由getAtt ...
- Mac版PhpStorm之XAMPP整合apache服务器配置
版权声明:本文为博主原创文章,未经博主允许不得转载. 选择在PhpStorm集成apache服务器,下面是我自己的亲测的步骤. 1.如何修改apache默认端口 xampp apache默认的http ...
- (转)[原] Android 自定义View 密码框 例子
遵从准则 暴露您view中所有影响可见外观的属性或者行为. 通过XML添加和设置样式 通过元素的属性来控制其外观和行为,支持和重要事件交流的事件监听器 详细步骤见:Android 自定义View步骤 ...
- Object-C关于GCD多线程的使用
```objc1 使用Crearte函数创建的并发队列和全局并发队列的主要区别: 1)全局并发队列在整个应用程序中本身是默认存在的并且对应有高优先级.默认优先级.低优先级和后台优先级一共四个并发队列, ...
- Android Activity生命周期与启动模式
Activity的完整生命周期如下图: Activity的加载模式有四种: standard: 标准模式,默认的加载模式,每次通过这种模式启动目标Acitivity,都创建一个新的实例,并将该Acti ...