UVA 11729 Commando War
2014-11-13 11:32
344 查看
链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2829
不摘抄题目了;
解析:
简单贪心思想;
不摘抄题目了;
解析:
简单贪心思想;
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #define MAXN 20005 #define RST(N)memset(N, 0, sizeof(N)) using namespace std; typedef struct Node_ { int b, j; }Node; Node N[MAXN]; int n; int cmp(const void *a, const void *b) { Node *p1 = (Node *)a; Node *p2 = (Node *)b; if(p1->j != p2->j) return p2->j - p1->j; else return p2->b - p1->b; } int max(int x, int y) { return x>y ? x:y; } int main() { int cas = 0; while(~scanf("%d", &n) && n) { for(int i=0; i<n; i++) { scanf("%d %d", &N[i].b, &N[i].j); } qsort(N, n, sizeof(Node), cmp); int res = 0, cnt = 0; for(int i=0; i<n; i++) { cnt += N[i].b; res = max(res, cnt+N[i].j); } printf("Case %d: %d\n", ++cas, res); } return 0; }
相关文章推荐
- UVA 11729 Commando War
- uva11729 Commando War 水题
- UVA 11729 STL - Commando War
- UVA 11729 - Commando War
- UVa Commando War 11729 (贪心)
- UVa 11729 - Commando War
- uva 11729 突击战 Commando War 思维
- UVA 11729 - Commando War
- UVa11729 - Commando War(贪心)
- uva_11729_Commando War(貪心)
- UVA - 11729 Commando War (贪心)
- 突击战(Commando War,UVa 11729)
- UVA 11729 - Commando War
- UVa 11729 - Commando War 题解
- UVA - 11729 - Commando War
- uva 11729 - Commando War(贪心)
- UVa 11729 Commando War 【贪心】
- UVA - 11729 Commando War 贪心
- UVA 之11729 - Commando War
- UVA 11729 Commando War