GIven this problem:
Given $$$n$$$ pairs $$$a_i$$$, $$$b_i$$$, pick $$$k$$$ of them so that $$$\frac{\sum_{}^{}a_i}{\sum_{}^{}b_i}$$$ is maximized, output the maximum value.
Constraints:
$$$1 \le k \le n \le 200000$$$
$$$a_i, b_i \le 10^{6}$$$
I have this scuffed greedy algorithm which does the following:
Assume the result is $$$\ge x$$$, then let $$$u_i = a_i - xb_i$$$
Greedily pick the largest $$$K$$$ values of $$$u_i$$$.
Update $$$x$$$ to the new optimal value, if the new value is not better then stop.
After a lot of random tests, the worst case only made it perform $$$7$$$ iterations.
Are there any tests that makes it TLE, or at least run a lot more than $$$7$$$ iterations? If not, is there a proof? What is the runtime worst case?



