Peng Lv

毋意,毋必,毋固,毋我。 言必行,行必果。

导航

POJ 1018 Communication System

//此题是DP问题,可是我一直没有想出公式
//组后只能根据带宽来枚举,再采用贪心策略

 

#include<iostream>
using namespace std;

int main()
{
    
int a[101][202],num[101],n,i,j,k,h,temp,tt;
    
int minb,minp,sump;
    
float bp,max;
    cin
>>tt;
    
while(tt--)
    {
        max
=0;
        scanf(
"%d",&n);
        
for(i=0;i<n;++i)
        {
            scanf(
"%d",&num[i]);
            
for(j=0;j<num[i];++j)
                scanf(
"%d%d",&a[i][j],&a[i][j+100]);
        }
        
for(i=0;i<n;++i)
            
for(j=0;j<num[i];++j)
            {
                minb
=a[i][j];
                sump
=a[i][j+100];
                
for(k=0;k<n;++k)
                {
                    
if(k==i) continue;
                    minp
=100000;
                    
for(h=0;h<num[k];++h)
                        
if(a[k][h]>=minb&&minp>a[k][h+100])
                            minp
=a[k][h+100];
                    sump
+=minp;
                    
if(minp==100000)
                        
break;
                }
                
if(minp==100000break;
                bp
=float(minb)/sump;
                
if(bp>max) max=bp;
            }
            printf(
"%.3f\n",max);
    }
    
    
return 1;
}

 

 

posted on 2010-02-03 16:28  Lvpengms  阅读(935)  评论(0编辑  收藏  举报