| ||||||||||
| 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 | |||||||||
Communication System 1018#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<set>
struct M
{int width;
int price;
};
int cmp(const void *a,const void *b)
{M *p=(M*)a;M *q=(M*)b;
return p->price>q->price;
}
using namespace std;
int main()
{M N[101][101];
set<int > P;
set<int>::iterator it;
int t,n,m, num[101];
cin>>t>>n;
for(int i=0;i<t;i++)
{
for(int j=0;j<n;j++)
{
cin>>num[j];
for(int k=0;k<num[j];k++)
{int width,price;
cin>>width>>price; P.insert (width); N[j][k].width=width; N[j][k].price=price;
}
}
for(int l=0;l<n;l++)
{
qsort(N+l,num[l],sizeof(M),cmp);
}
double maxBP=-1;
while(!P.empty())
{it=P.begin ();int width=*it,sumP,Price=-1;
double lBP=-1;
sumP=0;
for(int j=0;j<n;j++)
{Price=-1;
for(int k=0;k<num[j];k++)
{
if(N[j][k].width>=width){
Price=N[j][k].price ;break;
}
}
if(Price==-1) break;
sumP+=Price;
}
if(Price!=-1)
{lBP=(double)width/sumP;
if(lBP>maxBP) maxBP=lBP;
}
P.erase(it);
}
printf("%0.3lf\n",maxBP);
}
return 0;
}
给个测试样例 不知道为什么通不过总是 WA
不知道没有考虑那种情况
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator