#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define eps 1e-7
const int maxn = 111111;
int n, k;
double x;
struct J{
int a, b;
int id;
bool operator <(const J & cmp) const {
return a-x*b > cmp.a-x*cmp.b;
}
}j[maxn];
bool C(double mid) {
x = mid;
sort(j, j+n);
double tota = 0.0, totb = 0.0;
for(int i = 0; i < k; i++) {
tota += j[i].a;
totb += j[i].b;
}
return tota/totb > mid;
}
int main() {
while(~scanf("%d%d", &n, &k)) {
double mx = 0.0;
for(int i = 0; i < n; i++) {
scanf("%d%d", &j[i].a, &j[i].b);
mx = max(mx, j[i].a*1.0/j[i].b);
j[i].id = i+1;
}
double L = 0.0, R = mx;
while(fabs(R-L) > eps) {
double mid = (L+R)/2;
if(C(mid)) L = mid;
else R = mid;
}
for(int i = 0; i < k; i++)
printf("%d%c", j[i].id, i == k-1 ? '\n' : ' ');
}
return 0;
}
POJ3662--Telephone Lines
最新推荐文章于 2022-01-20 16:22:23 发布