标签:影响 lin view including mes opened eve ref lan
题目链接:http://poj.org/problem?id=3045
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 5713 | Accepted: 2151 |
Description
Input
Output
Sample Input
3 10 3 2 5 3 3
Sample Output
2
Hint
Source
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 #include <stack> 9 #include <map> 10 #include <string> 11 #include <set> 12 #define ms(a,b) memset((a),(b),sizeof((a))) 13 using namespace std; 14 typedef long long LL; 15 const double EPS = 1e-8; 16 const int INF = 2e9; 17 const LL LNF = 2e18; 18 const int MAXN = 1e5+10; 19 20 struct node 21 { 22 int w, s; 23 bool operator<(const node &x)const{ 24 return (w+s)<(x.w+x.s); 25 } 26 }a[MAXN]; 27 28 29 int main() 30 { 31 int n; 32 while(scanf("%d", &n)!=EOF) 33 { 34 for(int i = 1; i<=n; i++) 35 scanf("%d%d", &a[i].w, &a[i].s); 36 sort(a+1, a+1+n); 37 LL ans = -INF, tot = 0; 38 for(int i = 1; i<=n; i++) 39 { 40 ans = max(ans, tot-a[i].s); 41 tot += a[i].w; 42 } 43 printf("%lld\n", ans); 44 } 45 }
标签:影响 lin view including mes opened eve ref lan
原文地址:http://www.cnblogs.com/DOLFAMINGO/p/7560185.html