uva11292 Dragon of Loowater
水题,排序遍历即可
- #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的更多相关文章
- 勇者斗恶龙UVa11292 - Dragon of Loowater
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=s ...
- uva11292 Dragon of Loowater(排序后贪心)
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...
- 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 ...
- The Dragon of Loowater
The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into ...
- uva 11292 Dragon of Loowater (勇者斗恶龙)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA它11292 - Dragon of Loowater
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- UVA 11292 Dragon of Loowater(简单贪心)
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...
- Dragon of Loowater
option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267" style="color:b ...
- 贪心/思维题 UVA 11292 The Dragon of Loowater
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...
随机推荐
- iOS_Swift初识之使用三种回调方式自定义Button
最近在学习Swift ,发现青玉伏案大神早期用OC写的一篇博客--IOS开发之自定义Button(集成三种回调模式) 很适合用来熟悉Swift的回调方式,于是我就用Swift翻版了一下,具体实现原理 ...
- HTML 图像显示
HTML 图像显示:图像标签:<img>,源属性:Src<img>是空标签,没有闭合标签,它只包含属性:显示图像时需要调用源属性src:src的值是图像的地址:语法:<i ...
- js调用页面打印
----------------------调用页面打印-------------------------------- <body> <div id="divPrint& ...
- 怎么用BarTender的格式刷
BarTender的新格式刷使您能够轻松地在模板上的多个对象之间共享格式.您可以在单个模板中以及在多个BarTender模板和文档之间复制对象样式.下面小编给大家来讲讲BarTender格式刷这一可用 ...
- Java中引用类型变量,对象,值类型,值传递,引用传递 区别与定义
一.Java中什么叫做引用类型变量?引用:就是按内存地址查询 比如:String s = new String();这个其实是在栈内存里分配一块内存空间为s,在堆内存里new了一个Stri ...
- eclipse简单使用
1.10个快捷键: 1. ctrl+shift+r:打开资源 Control-Shift-T: 打开类型(Open type) Control-Shift-F: CodeàJavaàPre ...
- 手机网页调试利器: Chrome
新开发的网页需要在手机或是模拟机上运行测试, 可以借助 Chrome提供的手机网页预览程序进行简单调试.查看 制作的网页是否能够适合各种手机型号使用. 下面所以下如何使用Chrome调试多类型手机网页 ...
- Redis执行Lua脚本的情况
第一个测试: 往Redis里面存入1000个Hash,每个Hash里面有100个元素(Key 0-99,值是Key^2). PHP代码,执行33s左右 <?php $redis = new Re ...
- 从click事件理解DOM事件流
事件流是用来解释页面上的不同元素接受一个事件的顺序,首先要明确两点: 1.一个事件的影响元素可能不止一个(同心圆理论),但目标元素只有一个. 2.如果这些元素都绑定了相同名称的事件函数,我们怎么知道这 ...
- NodeJs:module.filename、__filename、__dirname、process.cwd()和require.main.filename
转载于: http://blog.csdn.net/bugknightyyp/article/details/17999473 module.filename:开发期间,该行代码所在的文件. __fi ...