水题,排序遍历即可

#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. ajaxpro 异步调用

    AjaxPro一般默认是同步调用,异步调用只需要在方法后面加一个callback函数,直接取value属性即可.例如: MyNameSpace.Page1.getOtherConfig("A ...

  2. notepad++

    plugin-manager 先要保证plugin-manager是最新的,然后才能下载其它的插件进行安装. compare插件,文件对比工具

  3. 总结.NET 中什么时候用 Static

    静态类和类成员用于创建无需创建类的实例就能够访问的数据和函数.当类中没有依赖对象标识的数据或行为时,就可以使用静态类.静态类成员是可独立于任何对象标识的数据和行为,即无论对象发生什么更改,这些数据和函 ...

  4. 转载:JAVA的静态变量、静态方法、静态类

    静态变量和静态方法都属于静态对象,它与非静态对象的差别需要做个说明. (1)Java静态对象和非静态对象有什么区别? 比对如下: 静态对象                                ...

  5. app升级方法

    1.到那里找apk? (1)Android Studio菜单Build->Generate Signed APK     (2)弹出窗口     (3)创建密钥库及密钥,创建后会自动选择刚创建的 ...

  6. 用RollViewPager实现Android滚动banner

    最近项目中要实现一个循环滚动的banner,效果如下图 这个自己写实在是不方便,而且写出来也很难保证没有bug和性能缺陷,好在网上有人开源了一个实现滚动banner的RollViewPager框架,亲 ...

  7. zabbix3.0安装之图形界面显示异常【server】

    前面记录过Zabbix3.0的安装过程,遇到一些坑,当时就在博文最后提到过,显示界面只有文字没有样式的问题.今天就解决这个小问题. 首先, 我们的安装是基于nginx作为web服务器的,不是传统的用A ...

  8. javascript基础二数据类型

    1.数据类型 javascript中的基本数据类型有4中,undefined,number,string,boolean 1.1 typeof关键字 typeof关键字可以获取一个变量的的类型.先举个 ...

  9. Ill-conditioned covariance create

    http://www.mathworks.com/matlabcentral/answers/100210-why-do-i-receive-an-error-while-trying-to-gene ...

  10. opencart在空间中安装出错,连接不上mysql

    客户要求,要在国外某空间安装opencart.话说opencart根本没怎么搞过,也不太清楚,php也是半吊子,临时看了几天,硬着头皮上把. 出错,安装进行到数据库连接设置的时候,死活连接不上,开始以 ...