水题,排序遍历即可

#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; const int maxn = ;
int drag[maxn], kn[maxn];
int main()
{
int n, m, cost;
while (cin >> n >> m) {
if(n == && m == )break;
for (int i = ;i < n;i++)cin >> drag[i];
for (int i = ;i < m;i++)cin >> kn[i];
sort(drag, drag + n);
sort(kn, kn + m);
int cur = ;
cost = ;
for (int i = ;i < m;i++) {
if (kn[i] >= drag[cur]) {
cost += kn[i];
if (++cur == n)break;
}
}
if (cur < n)cout << "Loowater is doomed!" << endl;
else cout << cost << endl;
}
return ;
}

uva11292 Dragon of Loowater的更多相关文章

  1. 勇者斗恶龙UVa11292 - Dragon of Loowater

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=s ...

  2. uva11292 Dragon of Loowater(排序后贪心)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...

  3. uva-----11292 The Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  4. The Dragon of Loowater

      The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into ...

  5. uva 11292 Dragon of Loowater (勇者斗恶龙)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  6. UVA它11292 - Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  7. UVA 11292 Dragon of Loowater(简单贪心)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  8. Dragon of Loowater

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267" style="color:b ...

  9. 贪心/思维题 UVA 11292 The Dragon of Loowater

    题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...

随机推荐

  1. C# Redis Server分布式缓存编程 --网络转载

    这篇文章我将介绍如果用最简洁的方式配置Redis Server, 以及如何使用C#和它交互编程 一. 背景介绍 Redis是最快的key-value分布式缓存之一 缺点: 没有本地数据缓冲, 目前还没 ...

  2. get和post的差异

    主要差异: 1.get在地址栏上回显示用户信息,安全性低,post采用加密方式传输不显示,安全性高. 2.get相比post提交方式较快一点,因为post封装了一次消息再发送(加密). 3.get方式 ...

  3. 如何将自己的windows设置为mysql服务器

    1.安装mysql 服务器 2.创建超级用户,即 用户管理 mysql>use mysql; 查看 mysql> select host,user,password from user ; ...

  4. [原创]cocos2d-x研习录-第三阶 特性之调度器

    在游戏中,经常会周期执行一些检测.操作或更新一些数据等,我们称之为调度.Cocos2D-x中将调度封装为类CCScheduler,方便在游戏开发中使用.我们一起来学习一下,CCScheduler具有哪 ...

  5. LINUX中如何查看某个进程打开的网络链接有多少

    使用lsof命令,比如查看sshd这个程序的网络连接使用命令 lsof -i | grep ^sshd

  6. Python数字,字符串

    数字 支持整数,浮点数,和奇怪的类型,如复数. 特殊的运算符为**,表示次方操作,如2**100,表示2的100次方. len()可以得到一个字符串对象的长度,str()可以将数字转换为字符串. pr ...

  7. ios 利用airprint实现无线打印(配合普通打印机)

    很多时候,我们不可能为了一个打印功能而去替换打印机,来支持无线打印. 找了很久,终于找到了一种解决方案,来适应大多数没有带wifi功能的打印机支持无线打印. 前提: 有wifi路由器:因为手机要打印, ...

  8. TCP打洞和UDP打洞的区别 (转)

    为什么网上讲到的P2P打洞基本上都是基于UDP协议的打洞?难道TCP不可能打洞?还是TCP打洞难于实现?     假设现在有内网客户端A和内网客户端B,有公网服务端S.     如果A和B想要进行UD ...

  9. Python 面向对象2

    静态方法 静态方法相当于函数,可以不创建对象直接引用 如果在类里面用静态方法,相当于函数,可以不创建对象,直接是用类里面的方法,你就当它是函数. 静态方法名义上归类管理,实际上静态方法访问不了类或实例 ...

  10. [经验交流] docker in docker 的变通实现方法

    最近在做CI持续集成环境的容器化,其中一个工作是:在容器中构建容器镜像. 对于这个需求,网上有一些 Docker in Docker 的方法,具体需要修改宿主机的配置.这种方式在单机环境下.对安全要求 ...