UVA 11729 Commando War
来源:互联网 发布:java面试逻辑思维题目 编辑:程序博客网 时间:2024/05/15 03:07
链接: 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;}
0 0
- 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
- UVA 11729 - 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
- hdu5094(BFS+状压)
- uvaoj 147 - Dollars 动态规划
- java内省操作
- linux之 sed的用法
- 多线程中引入Spring自动注入的对象为null
- UVA 11729 Commando War
- Android 快速开发框架androidannotations详解
- c# 集合
- 背景选择器Selector和.9.png的使用
- 理解 JMeter 聚合报告(Aggregate Report)
- libvlc外部api的简单整理
- tof相机很好的总结~
- 我眼中的并查集
- 解读淘宝”搜刮九年夜规矩“,让流量爆棚(新店也可以哦)