基础题,看了一下知识点,挑了个最简单的下手了,好久没有的1Y。
ACcode:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int NS=1010;
const double eps=1e-4;
int n,k;
double a[NS],b[NS],c[NS];
double get_op(double x)
{
for (int i=0;i<n;i++)
c[i]=100.0*a[i]-b[i]*x;
sort(c,c+n);
double ans=0;
for (int i=n-1;i>=k;i--)
ans+=c[i];
return ans;
}
int main()
{
while (~scanf("%d %d",&n,&k)&&(n+k))
{
for (int i=0;i<n;i++)
scanf("%lf",&a[i]);
for (int i=0;i<n;i++)
scanf("%lf",&b[i]);
double low=0.0,high=1e18;
while (high-low>eps)
{
double mid=(low+high)/2.0;
if (get_op(mid)>0) low=mid;
else high=mid;
}
printf("%.0lf\n",low);
}
return 0;
}