#include<stdio.h>
#include<stdlib.h>
int m[15];
struct node
{
int b,p;
}device[105][105];
int cmp(const void *a,const void *b)
{
struct node *aa=(node*)a;
struct node *bb=(node*)b;
return aa->p-bb->p;
}
int main()
{
freopen("t.txt","r",stdin);
int T,n,i,j;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&m[i]);
for(j=0;j<m[i];j++)
{
scanf("%d%d",&device[i][j].b,&device[i][j].p);
}
qsort(device[i],m[i],sizeof(device[1][1]),cmp);
}
double max=-1;
for(i=0;i<n;i++)
for(j=0;j<m[i];j++)
{
int b=device[i][j].b;
int ok2=0,sum=0;
for(int x=0;x<n;x++)
{
int ok=0;
for(int y=0;y<m[x];y++)
if(device[x][y].b>=b)
{
sum+=device[x][y].p;
ok=1;
break;
}
if(!ok){ok2=1;break;}
}
if(ok2)continue;
else {
double t=b*1.0/sum;
if(t>max)max=t;
}
}
printf("%.3lf\n",max);
}
return 0;
}
ZOJ1409 Communication System贪心
最新推荐文章于 2019-04-22 20:59:12 发布