POJ-1887
2015-09-19 19:35
281 查看
#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; }
相关文章推荐
- C++ 空类默认产生的类成员函数
- 老猴子排序
- 树的子结构
- Java基金会——JUnit
- Linux内核笔记——内存管理之slab分配器
- 多态解读
- netstat查看端口指令
- GoldenGate 配置
- 本库主要提供一些类和一些函数来比较不同序列对象
- JAVA学习资源种子
- Unity3d NGUI伪自适应
- 阶梯问题
- 测试要点的提取
- QT对话框中show和exec的区别
- Java事件类型小结
- Oracle学习笔记20150919异常处理表与方案的备份
- View机制深入学习(三) View中的消息传递及InputManagerService
- HDU 5455.Fang Fang【2015 ACM/ICPC Asia Regional Shenyang Online】【字符串处理】9月19
- Dom4J对XML文件的读取和写入
- Codeforces Round #319 (Div. 2) (ABCE题解)