UVA 1192 Dragon of Loowater
来源:互联网 发布:淘宝店铺怎么来搞信誉 编辑:程序博客网 时间:2024/04/30 13:16
【题目分析】
一道贪心的水题,处理好边界会十分简单。uva网站上的魔性配图也是6得飞起。
【代码】
#include <cstdio>#include <algorithm>using namespace std;const int maxn=20000+5; int a[maxn],b[maxn];int main(){ int n,m; while (scanf("%d%d",&n,&m)==2&&n){ for (int i=0;i<n;++i) scanf("%d",&a[i]); for (int i=0;i<m;++i) scanf("%d",&b[i]); sort(a,a+n),sort(b,b+m); int cur=0,cost=0; for (int i=0;i<m;++i) if (b[i]>=a[cur]) {cost+=b[i];if (++cur==n) break;} if (cur<n) printf("Loowater is doomed!\n"); else printf("%d\n",cost); }}
0 0
- UVA 1192 Dragon of Loowater
- Dragon of Loowater UVA
- Dragon of Loowater UVA
- Dragon of Loowater UVA
- Dragon of Loowater UVA
- uva --11292 --Dragon of Loowater
- UVa 11292 - Dragon of Loowater
- uva - 11292 - Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- uva 11292 - Dragon of Loowater
- Uva-11292-Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- UVA 11292 Dragon of Loowater
- uva 11292 - Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- UVA 11292 Dragon of Loowater
- UVA 11292 Dragon of Loowater
- uva 11291 Dragon of Loowater
- linux web服务器搭建
- Android使用Bitmap、Canvas制作图片
- lintcode ----两个链表的交叉
- html的for循环嵌套实现排序
- 脱壳
- UVA 1192 Dragon of Loowater
- DMA与普通中断方式的区别
- 很特别的一个动态规划入门教程
- 详解C中volatile关键字
- ShareSDK For Unity的使用
- Qt学习笔记1
- Android framework 修改系统音量条背景图片
- 部署在VM上的vCenter迁移
- 【MongoDB】上传示例