uva11292 Dragon of Loowater
Posted ArvinShaffer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uva11292 Dragon of Loowater相关的知识,希望对你有一定的参考价值。
水题,排序遍历即可
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn = 20010; int drag[maxn], kn[maxn]; int main() { int n, m, cost; while (cin >> n >> m) { if(n == 0 && m == 0)break; for (int i = 0;i < n;i++)cin >> drag[i]; for (int i = 0;i < m;i++)cin >> kn[i]; sort(drag, drag + n); sort(kn, kn + m); int cur = 0; cost = 0; for (int i = 0;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 0; }
以上是关于uva11292 Dragon of Loowater的主要内容,如果未能解决你的问题,请参考以下文章
UVA 11292 Dragon of Loowater(简单贪心)
UVa 11292 - Dragon of Loowater