#include <iostream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
int matrix[1024],cnt = 0;
int main()
{
int n, m,id = 0;
while (cin >> n >> m && n && m) {
long long int diff = 0,c = 1,v,t = 0;
double high;
cnt = 0;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> matrix[cnt++];
}
}
matrix[cnt++] = 0x7FFFFFFF;
cin >> v;
high = v / 100.0;
sort(matrix, matrix + cnt);
for (; c < cnt; c++) {
diff = matrix[c] - matrix[c - 1];
high -= t;
t = diff * c;
if(t < high) continue;
high = matrix[c - 1] + high / c;
break;
}
cout << "Region "<<++id << endl;
cout << "Water level is "<<fixed <<setprecision(2)<<high <<" meters." << endl;
cout <<fixed << setprecision(2) << c / (cnt-1.0) * 100 <<" percent of the region is under water." << endl<<endl;
}
}
习题4-10(uva-815)
最新推荐文章于 2021-04-05 14:15:13 发布