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 ...
随机推荐
- ValidateRequest问题
1,在出现该错误的页面头部的page中加入ValidateRequest="false",那么该页面的任何一次Post提交都不会再验证提交内容的安全性.如: <%@ Page ...
- go语言的命令行库
命令行应用通常很小,程序猿们也不喜欢为它编写注释.所以一些额外的工作,如解析参数有个合理的库来帮忙做就好了.https://github.com/urfave/cli 这个项目因此而生.安装:go g ...
- Android studio 快捷键(Mac)
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- Codis集群
一.简介 Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Re ...
- api接口验证shal()
就安全来说,所有客户端和服务器端的通信内容应该都要通过加密通道(HTTPS)传输,明文的HTTP通道将会是man-in-the- middle及其各种变种攻击的温床.所谓man-in-the-midd ...
- 1、SQL可搜索可排序可分页存储过程, 2、范围内的随机时间 适用于sql 2008以上
-- ============================================= -- Author: 蜘蛛王 -- Create date: 2015-10-29 -- Descri ...
- 如何提高ASP.NET页面载入速度的方法
前言 本文是我对ASP.NET页面载入速度提高的一些做法,这些做法分为以下部分: 1.采用 HTTP Module 控制页面的生命周期. 2.自定义Response.Filter得到输出流stream ...
- MariaDB Galera Cluster部署手册
MariaDB Galera Cluster部署手册 galara保证双主数据库的同步及一致性 1.环境准备 基于新部署.最小化安装centos6.5 1> yum install opens ...
- 缓存AsimpleCache -- 解决Android中Sharedpreferences无法存储List数据/ASimpleCache
Sharedpreferences想必大家在项目中都经常会用到,但是如果需要在本地需要存储比较多的数据,存储一个集合的时,发现Sharedpreferences并不 是那么好使了. 分析 如果需要在本 ...
- maven详解之生命周期与插件
Maven是一个优秀的项目管理工具,它能够帮你管理编译.报告.文档等. Maven的生命周期: maven的生命周期是抽象的,它本身并不做任何的工作.实际的工作都交由"插件"来完成 ...