二分
LA上的题目居然和原题有差别!变成了多组数据
下面这个程序是按原题写的
#include <iostream>
#include <cstdio>
#include <algorithm>
int main() {
int n, t;
std::cin >> n >> t;
double d[1000], s[1000];
for (int i = 0; i < n; i++)
std::cin >> d[i] >> s[i];
double l = -*std::min_element(s, s + n), r = 1001000;
while (l + 2e-10 <= r) {
double mid = l + (r - l) / 2, t_ = 0;
for (int i = 0; i < n; i++)
t_ += d[i] / (s[i] + mid);
if (t_ < t)
r = mid;
else
l = mid;
}
printf("%.9lf\n", l);
return 0;
}