uva 11292 勇者斗恶龙
来源:互联网 发布:卖毛线比较好的淘宝店 编辑:程序博客网 时间:2024/04/30 03:10
有一条n个头恶龙,m个骑士,一个能力值为x的骑士能砍掉直径不超过x的头,且需要支付x金币。砍掉所有的恶龙所有的头,且支付金币最少?
头直径和骑士能力从小到大排序,一个个砍。
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 20005;
int a[maxn];
int b[maxn];
int main()
{
int n, m;
while (cin>>n>>m && n && m)
{
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < m; i++)
cin >> b[i];
sort(a, a + n);
sort(b, b + m);
int cur = 0;
int cost = 0;
for (int i = 0; i < m; i++)
{
if (b[i] >= a[cur])
{
cur++;
cost += b[i];
if (cur == n)
break;
}
}
if (cur < n)
cout << "Loowater is doomed!\n";
else
cout << cost << endl;
}
return 0;
}
0 0
- UVA 11292 勇者斗恶龙
- UVA 11292 勇者斗恶龙
- uva 11292 勇者斗恶龙
- 勇者斗恶龙UVa 11292
- UVA 11292 勇者斗恶龙,排序
- UVA 11292(Dragon of Loowater-勇者斗恶龙)
- UVa 11292 Spreading the Wealth 勇者斗恶龙
- 勇者斗恶龙(The Dragon Loowater,UVA 11292)
- uva 11292 Dragon of Loowater (勇者斗恶龙)
- 勇者斗恶龙(The Dragon of Loowater) UVa 11292 HDU 1902
- uva 11292 Dragon of Loowater (勇者斗恶龙系列)
- 勇者斗恶龙(The Dragon of Loowater, UVa 11292)
- UVa 11292 The Dragon of Loowater 勇者斗恶龙
- uva 11292 勇者斗恶龙 The Dragon of Loowater
- 勇者斗恶龙(The Dragon of Loowater, UVa 11292)
- 例题5-1 UVA 11292 The Dragon of Loowater勇者斗恶龙
- 勇者斗恶龙
- 勇者斗恶龙
- 策略设计模式
- [UOJ241]【UR #16】破坏发射台 矩阵快速幂
- 搜狐狐友与腾讯微信两款社交软件的比较
- LeetCOde412详细分析并附求解代码
- 临时车牌相关问题
- uva 11292 勇者斗恶龙
- 嵌入式开发叙述
- 服务器(多GPU)caffe安装和编译
- 【Unity&NGUI】背包系统物品的累加
- Consul 入门笔记
- Read File in Python
- DIGITS安装和配置
- 关于逐项作用函数的用法
- 新手看Mockplus2.3