#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(int argc, char *argv[]){
int m,n;
int index=0;
while(cin>>m>>n,m|n){
index++;
vector<int> v;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
int height;
cin>>height;
v.push_back(height);
//cout<<"add: "<<height<<endl;
}
}
sort(v.begin(),v.end());
int walterVolume;
cin>>walterVolume;
int sumLand=0;
int baseHeight=0;
int curHeight;
for(vector<int>::iterator iter=v.begin();iter!=v.end();++iter){
if(iter==v.begin()){
baseHeight=*iter;
curHeight=baseHeight;
sumLand++;
continue;
}
curHeight=*iter;
int addWalter=sumLand*(curHeight-baseHeight)*100;
if(addWalter>=walterVolume){
break;
}else{
walterVolume-=addWalter;
baseHeight=curHeight;
sumLand++;
//cout<<"walterVolume= "<<walterVolume<<endl;
}
}
float walterHeight=baseHeight+walterVolume*1.0/100/sumLand;
float persent=100*sumLand*1.0/v.size();
cout<<"Region "<<index<<endl;
printf("Water level is %0.2f meters.\n",walterHeight);
printf("%0.2f percent of the region is under water.\n",persent);
}
return 0;
}
POJ-1887
最新推荐文章于 2020-05-02 19:30:48 发布