# 範例程式碼 uva815

```//uva815
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main() {
int m = 0, n = 0, R = 0;

while (cin >> m >> n && m && n) {
int w = 0, h_sum = 0, out_index = 0;
vector<int> block;

// Input
for (int i = 0; i < m * n; i++) {
int e;
cin >> e;
block.push_back(e);
}
block.push_back(INT_MAX / 100 / m / n);
cin >> w;

// Process
sort(block.begin(), block.end());

int remain_w = w;
for (int i = 1; i <= m * n; i++) {
int diff = 0;
if (block[i] != block[i - 1]) {
diff = block[i] - block[i - 1];
if (remain_w > diff * 100 * i) {
remain_w -= diff * 100 * i;
} else {
out_index = i;
h_sum += block[i - 1];
break;
}
}
h_sum += block[i - 1];
}

// Output
cout << fixed << setprecision(2);
cout << "Region " << ++R << endl;
cout << "Water level is " << 0.01 * (w + 100 * h_sum) / out_index
<< " meters." << endl;
cout << 100.0 * out_index / m / n
<< " percent of the region is under water." << endl
<< endl;
}
return 0;
}
```