#include
#include
int h[1000000]; //保存每个格子的高度值,因不知m和n的范围,故高的比较大
int cmp(const void *a, const void *b)
{
return *((int *)a) - *((int *)b);
}
main()
{
int t,m,n,nn;
double x,hw;
int i;
t=0;
while(1)
{
scanf("%d%d",&n,&m);
if(n==0 && m==0)
break;
t++;
nn=m*n;
for(i=0;i {
scanf("%d",&h[i]);
}
scanf("%lf",&x);
//排序
qsort(h,nn,sizeof(int),cmp);
i=0;
hw=h[0];
if(x>0)
{
for(i=1;i {
//在高度相等的情况下,扩大水面面积
while(i i++;
//若剩下的水不足以使水面达到覆盖下一格子,退出
if(i==nn || x<=100*i*(h[i]-h[i-1]))
break;
x-= i*(h[i]-h[i-1])*100;
}
hw = h[i-1];
}
//若剩下水,就把它铺在当前的范围上
if(x>0)
hw+=x/i/100;
printf("Region %d\n",t);
printf("Water level is %.2f meters.\n",hw);
printf("%.2f percent of the region is under water.\n\n",i*100/double(nn));
}
}
阅读(1216) | 评论(0) | 转发(0) |