#include #include #include #include #include #include #include #include using namespace std; typedef signed long long ll; int pred(pair first, pair second) { return first.second < second.second; } int main() { ll n; cin >> n; vector values(n); for(int i = 0; i < n;i++) { cin >> values[i]; } int q; cin >> q; vector> length(q); vector results(q); for(int i = 0; i < q;i++) { ll value; cin >> value; length[i] = make_pair(i, value); } sort(length.begin(), length.end(), pred); double totalMin = 0; double totalMax = 1e9; int left = 0; int right = q-1; while(true) { { double minValue = totalMin; double maxValue = totalMax; double threshold = length[left].second; while(maxValue - minValue > 1e-10) { double mid = (minValue + maxValue)/2.0; ll sum = 0; for (int i = 0; i < n; i++) { sum += (ll)(values[i]/mid); } if (sum >= threshold) { minValue = mid; } else { maxValue = mid; } } results[length[left].first] = minValue; totalMax = min(totalMax, minValue); if(left >= right) { break; } left++; } { double minValue = totalMin; double maxValue = totalMax; double threshold = length[right].second; while(maxValue - minValue > 1e-10) { double mid = (minValue + maxValue)/2.0; ll sum = 0; for (int i = 0; i < n; i++) { sum += (ll)(values[i]/mid); } if (sum >= threshold) { minValue = mid; } else { maxValue = mid; } } results[length[right].first] = minValue; totalMin = max(totalMin, minValue); if(left >= right) { break; } right--; } } for(int m = 0;m < q;m++) { printf("%.15f\n", results[m]); } }