#include<bits/stdc++.h>
#define N n*m
#define debu
using namespace std;
const int maxn=1000;
int n,m;
double a[maxn];
int main()
{
#ifdef debug
freopen("in.in","r",stdin);
#endif
int cas=0,ans;
double tot=0.0;
while(scanf("%d%d",&n,&m)==2&&n)
{
for(int i=0; i<N;i++)
scanf("%lf",&a[i]);
scanf("%lf",&tot);
tot/=100.0;
sort(a,a+N);
a[N]=9999999.0;
for(int i=1; i<=N; i++)
{
tot+=a[i-1];
if(tot/(double)i<=a[i])
{
ans=i;
break;
}
}
printf("Region %d\n",++cas);
printf("Water level is %.2f meters.\n",tot/(double)ans);
double tmp=(double)ans*100.0/(n*m);
printf("%.2f percent of the region is under water.\n\n",tmp);
}
return 0;
}
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=756
UVA 815(p99)----Flooded!
最新推荐文章于 2018-11-02 09:13:00 发布