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

注意题目意思

Posted by 2018339960034 at 2019-07-29 19:54:27 on Problem 3045
是最大的risk 最小  不是risk和最小
顺便附上我的代码
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
const int maxn=5e4+9;
struct node
{
	ll w,s;
}cow[maxn];
int cmp(node a,node b)
{
	return (a.w+a.s)<=(b.w+b.s);
}
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%lld%lld",&cow[i].w,&cow[i].s);
		}
		sort(cow+1,cow+n+1,cmp);
		ll sumw=0,ans=-0x3f3f3f3f3f3f3f3f;
		for(int i=1;i<=n;i++)
		{
			ll temp=sumw-cow[i].s;
			ans=max(ans,temp);
			sumw+=cow[i].w;
		}
		printf("%lld\n",ans);
	}
	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