pre win tor fine not in tar earch i++
题目链接: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
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <map>
- #include <string>
- #include <set>
- #define ms(a,b) memset((a),(b),sizeof((a)))
- using namespace std;
- typedef long long LL;
- const double EPS = 1e-8;
- const int INF = 2e9;
- const LL LNF = 2e18;
- const int MAXN = 1e5+10;
- struct node
- {
- int w, s;
- bool operator<(const node &x)const{
- return (w+s)<(x.w+x.s);
- }
- }a[MAXN];
- int main()
- {
- int n;
- while(scanf("%d", &n)!=EOF)
- {
- for(int i = 1; i<=n; i++)
- scanf("%d%d", &a[i].w, &a[i].s);
- sort(a+1, a+1+n);
- LL ans = -INF, tot = 0;
- for(int i = 1; i<=n; i++)
- {
- ans = max(ans, tot-a[i].s);
- tot += a[i].w;
- }
- printf("%lld\n", ans);
- }
- }
POJ3045 Cow Acrobats —— 思维证明
来源: http://www.bubuko.com/infodetail-2316487.html