| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
wa??????????#include<iostream.h>
int main()
{
double a[1010],b[1010];
int n,k;
while(cin>>n>>k)
{
if(n==0&&k==0)break;
int i,j;
double c[1010]={0};
int cur=0;
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
cin>>b[i];
}
double max=0;
double temp=0;
for(i=0;i<n;i++)
{
temp=a[i]/b[i];
if(temp>max)
{
cur=i;
max=temp;
}
}
//cout<<endl;
double aa=a[cur],bb=b[cur];
c[cur]=1;
int count=1;
for(i=0;i<n;i++)
{
if(count==n-k)break;
if(c[i]==0)
{
double s=(aa+a[i])/(bb+b[i]);
cur=i;
for(j=0;j<n;j++)
{
if(c[j]==0&&i!=j)
{
double run=(aa+a[j])/(bb+b[j]);
if(run>s)
{
s=run;
cur=j;
}
}
}
c[cur]=1;
count++;
aa+=a[cur];
bb+=b[cur];
}
}
cout<<(int)(100*aa/bb)<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator