标签:otto ace 需要 which psi bin detail using nes
Input
Output
Sample Input
3 10 3 2 5 3 3
Sample Output
2
Hint
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <iostream> #define MAXN 50100 #define ll long long using namespace std; struct node{ int w,s; }a[MAXN*2]; int n; bool cmp(node x,node y){ return x.w+x.s<y.w+y.s; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d",&a[i].w,&a[i].s); sort(a+1,a+n+1,cmp); int ans=-(1<<30),sum=0; for(int i=1;i<=n;i++){ ans=max(ans,sum-a[i].s); sum+=a[i].w; } printf("%d\n",ans); return 0; }
标签:otto ace 需要 which psi bin detail using nes
原文地址:http://www.cnblogs.com/renjianshige/p/7509468.html