UVa 11292 Dragon of Loowater——思路题
2017-05-25 18:18
447 查看
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 20000 + 10; int a[maxn], b[maxn]; int main() { int n, m; while (scanf("%d %d", &n, &m) == 2 && n + m) { for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= m; i++) scanf("%d", &b[i]); sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + m); int i, j = 1, ans = 0; for (int i = 1; i <= m; i++) { if (b[i] >= a[j]) { j++; ans += b[i]; if (j > n) break; } } if (j > n) printf("%d\n", ans); else printf("Loowater is doomed!\n"); } }
相关文章推荐
- uva11292 Dragon of Loowater
- Uva 11292 The Dragon of Loowater 模拟题
- UVa 11292 - Dragon of Loowater
- UVA_11292_Dragon of Loowater
- UVA11292 - Dragon of Loowater
- UVA 11292(Dragon of Loowater-勇者斗恶龙)
- uva --11292 --Dragon of Loowater
- UVa 11292 - Dragon of Loowater
- UVA它11292 - Dragon of Loowater
- Dragon of Loowater UVA - 11292 (水)
- UVa 11292 The Dragon of Loowater 【贪心】
- |UVA 11292|贪心|Dragon of Loowater
- uva-11292-Dragon of Loowater
- Uva 11292 Dragon of Loowater - 水题
- uva11292 The Dragon of Loowater (排序+贪心)
- UVA 11292-Dragon of Loowater (思维)
- 指南第一章 例题一 UVA 11292 Dragon of Loowater(贪心算法)
- Dragon of Loowater(UVa 11292)
- UVa 11292 Dragon of Loowater
- UVA 11292 - Dragon of Loowater