Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

WA求救

Posted by jiexianzhu at 2011-03-15 17:20:33 on Problem 1018
#include <iostream>
using namespace std;

struct DEV
{
	int band;
	int price;
};

DEV device[120][11];

int main()
{
	int cas, n, i, j, ii, jj;
	float small_res;
	cin>>cas;
	while( cas-- )
	{
		cin>>n;
		for( i=1 ; i<=n ; i++)
		{
			cin>>device[i][0].band;
			for(j=1; j<=device[i][0].band ;j++)
			{
				cin>>device[i][j].band >> device[i][j].price;
			}
		}

		int min_band, min_price, total;
		small_res=0.0;
		for(ii=1; ii<=n ; ii++)
		{
			for(jj=1 ; jj<=device[ii][0].band ; jj++)
			{
				min_band = device[ii][jj].band;
				total=device[ii][jj].price;

				for(i=1 ; i<=n ; i++)
				{
					if(i == ii)
						continue;
					min_price = 10000001;
					for(j=1 ; j<=device[i][0].band ; j++)
					{
						if(device[i][j].band >= min_band && device[i][j].price < min_price)
						{
							min_price = device[i][j].price;
						}
					}
					total += min_price;
					if(min_price == 10000001)
					{
						break;
					}
				}
				if(min_price ==10000001)
					break;
				float dp = (float)min_band / (float)total;
				if(dp > small_res)
				{
					small_res = dp;
				}
			}
		}
		printf("%.3f\n",small_res);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator