UVa 815

来源:互联网 发布:快乐打字员软件 编辑:程序博客网 时间:2024/06/05 03:47
#define LOCAL0#include <stdlib.h>#include <stdio.h>#include "iostream"#include "sstream"#include <string.h>#include <cmath>#include "algorithm"#define inf 0x3f3f3f3fusing 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;}

0 0
原创粉丝点击