1 条题解
-
0
by hansang:
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long LL; struct node{LL w, s;} a[N]; bool cmp(node n1, node n2){ return (n1.w-n2.s)<(n2.w-n1.s); } int main(){ int n; scanf("%d", &n); for(int i=1; i<=n; i++){ scanf("%lld%lld", &a[i].w, &a[i].s); } sort(a+1, a+n+1, cmp); LL sum=0, ans=-1e9; for(int i=1; i<=n; i++){ ans=max(ans, sum-a[i].s); sum+=a[i].w; } printf("%lld\n", ans); return 0; }
- 1
信息
- ID
- 2625
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 9
- 已通过
- 6
- 上传者