| ||||||||||
| 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 | |||||||||
注意题目意思是最大的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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator