UVa 815

#define LOCAL0
#include <stdlib.h>
#include <stdio.h>
#include "iostream"
#include "sstream"
#include <string.h>
#include <cmath>
#include "algorithm"
#define inf 0x3f3f3f3f
using namespace std;

int main(int argc, char const *argv[])
{
	#ifdef LOCAL
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    double H;
    int m,n,tv,v,scnt,pcnt=0,i,j,lev[1000];
    while(cin>>m>>n,m&&n){
    	for(i=0;i<m*n;i++)
    		cin>>lev[i];
    	cin>>tv;
    	sort(&lev[0],&lev[m*n]);
    	H=lev[0];
    	for(j=0,scnt=1;j<m*n-1;++j,++scnt){
    		if(lev[j]==lev[j+1]) continue;
    		else{
    			v=100*(lev[j+1]-lev[j])*scnt;
    			if(v>=tv){
    				H=H+1.0*tv/scnt/100;
    				tv=0;
    				break;
    			}
    			else{
    				tv=tv-v;
    				H=H+(lev[j+1]-lev[j]);
    			}
    		}
    	}
    	if(tv>0){
    		H=H+1.0*tv/m/n/100;
    	}
    	double par=0.0;
    	for(i=0;i<m*n;++i){
    		if(H<lev[i])
    			break;
    	}
    	if(i==m*n) par=1;
    	else
    		par=1.0*i/m/n;
    	printf("Region %d\nWater level is %.2f meters.\n%.2f percent of the region is under water.\n\n", ++pcnt,H,par*100);
    }

	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值