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

Re:有什么注意点,wa了两把了

Posted by skogt at 2010-08-20 10:41:45 on Problem 2082
In Reply To:有什么注意点,wa了两把了 Posted by:skogt at 2010-08-20 10:24:57
> 有什么注意点,wa了两把了
#include<iostream>
#include<algorithm>
using namespace std;

struct In
{
	int x;
	int y;
}arr[50001];
int ans[50001];

int main()
{
	int n;
	while(scanf("%d",&n) && n!=-1)
	{
		int minh=9999999;
		int totalw=0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&arr[i].x,&arr[i].y);
			if(arr[i].y<minh)
				minh=arr[i].y;
			totalw+=arr[i].x;
			ans[i]=arr[i].x*arr[i].y;
		}
		sort(ans,ans+n);
		int s;
		s=totalw*minh;
		printf("%d\n",s>ans[n-1] ? s : ans[n-1]);

	}
	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