UVA 11292 - Dragon of Loowater
2015-09-06 15:02
281 查看
题目传送门
红果果的贪心,外加一点点的优化,大约能快个0.01s....
好像并没有什么卵用
红果果的贪心,外加一点点的优化,大约能快个0.01s....
好像并没有什么卵用
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int a[20010], b[20010]; int n, m; int main(){ #ifdef sxy freopen("in.txt", "r", stdin); #endif //sxy while(~scanf("%d%d",&n,&m)){ if(!n && !m) break; for(int i=0; i<n; i++) scanf("%d", &a[i]); for(int j=0; j<m; j++) scanf("%d", &b[j]); if(n>m) { printf("Loowater is doomed!\n"); continue;} sort(a, a+n); sort(b, b+m); int count = 0,sum = 0; for(int i=0; i<m; i++){ if(b[i] >= a[count]){ sum += b[i]; count ++; } if(count == n) break; } if(count < n) printf("Loowater is doomed!\n"); else printf("%d\n", sum); } return 0; }
相关文章推荐
- 奇虎360 和 Go
- Google也许要重回中国市场了
- mongo中$push的$slice子操作符的理解
- leetcode: (35) Search Insert Position
- Algorithms - Week 3-0 Mergesort
- Algorithms - Week 2-1 Elementary Sorts
- Goods:查询某个用户的购物车条目以及添加购物车条目
- Intent中的四个重要属性——Action、Data、Category、Extras
- go-tour-zh离线安装
- golang-反射机制
- godaddy.com 注册域名 买卖域名
- [转]为什么GOF的23种设计模式里面没有MVC?
- mongo备份与恢复工具的对比与说明
- 外媒:Google Play将重返中国大陆
- leetcode: (94) Binary Tree Inorder Traversal
- Django:手把手带你入门
- Go基本语句
- 中国正沦为3D打印的配角?
- Going Graphical — The dialog Utility
- Godaddy域名因为whois信息虚假被暂时关闭