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 ...
随机推荐
- Oracle Hints详解
在向大家详细介绍Oracle Hints之前,首先让大家了解下Oracle Hints是什么,然后全面介绍Oracle Hints,希望对大家有用.基于代价的优化器是很聪明的,在绝大多数情况下它会选择 ...
- 移动支持 – ASP.NET MVC 4 系列
目前,有各种各样的方法可以提高网站应用程序的移动体验.在某些情况下,我们只想在小规格上做一些微小的风格变化:另一些情况下,我们可能完全改变外观显示或者一些视图的内容:最极端的情况下,我们 ...
- python-语句
assert语句 用来声明某个条件是真的.例如,如果你非常确信某个你使用的列表中至少有一个元素,而你想要检验这一点,并且在它非真的时候引发一个错误,那么assert语句是应用在这种情形下的理想语句.当 ...
- pm2使用
简单教程 首先需要安装pm2: npm install -g pm2 运行: pm2 start app.js 初次安装并运行,会有一个高大上的界面: 高大上的界面 直接我们介绍过forever,那么 ...
- 转载:python中的StringIO模块
注意:python3中应使用io.StringIO StringIO经常被用来作为字符串的缓存,应为StringIO有个好处,他的有些接口和文件操作是一致的,也就是说用同样的代码,可以同时当成文件操作 ...
- Validation failed for one or more entities.
验证失败后用DbEntityValidationException 查找出错的字段 try { // Your code... // Could also be before try if you k ...
- 【python】遍历类的所有成员
# -*- coding: utf-8 -*- #sharejs.com提供代码,转载请注明出处 class Site(object): def __init__(self): self.title ...
- java并发编程系列
1.多线程的概念与使用:java笔记五:多线程的使用 2.多线程产生的问题,解决的方法, 1.引入线程池的原因:Java并发编程:线程池的使用 2.高并发情况下数据库提交:jdbc事务处理, 理解事务 ...
- C#:生成短网址
/// <summary> /// 短网址应用 ,例如QQ微博的url.cn http://url.cn/2hytQx /// </summary> /// <param ...
- MyBatis入门学习教程-使用MyBatis对表执行CRUD操作
上一篇MyBatis学习总结(一)--MyBatis快速入门中我们讲了如何使用Mybatis查询users表中的数据,算是对MyBatis有一个初步的入门了,今天讲解一下如何使用MyBatis对use ...