Uva-11292-Dragon of Loowater
2013-03-15 08:57
267 查看
比较典型的贪心题, 尽量找到能力值最小的骑士去杀死恶龙。
代码:
代码:
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define MAX 20001 using namespace std; int n,m,a[MAX],b[MAX]; int main() { while(scanf("%d%d",&n,&m)&&(n||m)) { for(int i=0;i<n;i++) scanf("%d",&a[i]); for(int i=0;i<m;i++) scanf("%d",&b[i]); sort(a,a+n); sort(b,b+m); int ans=0,cou=0,i; for(i=0;i<n;i++) { while(cou<m&&b[cou]<a[i]) cou++; if(cou<m) ans+=b[cou++]; else break; } if(i==n) printf("%d\n",ans); else printf("Loowater is doomed!\n"); } return 0; }
相关文章推荐
- UVA - 11292 Dragon of Loowater
- Uva 11292 Dragon of Loowater - 水题
- 【UVa】11292 - Dragon of Loowater
- UVaThe Dragon of Loowater-11292(排序+贪心)
- Dragon of Loowater(UVa 11292)
- [UVA] 11292 - Dragon of Loowater
- UVA 11292 - The Dragon of Loowater (water)
- UVA 11292-Dragon of Loowater (思维)
- UVA它11292 - Dragon of Loowater
- UVA 11292 The Dragon of Loowater 英文略长略长
- uva --11292 --Dragon of Loowater
- UVA - 11292 Dragon of Loowater ( 排序 贪心 )
- UVa 11292 Dragon of Loowater (水题,排序)
- 勇者斗恶龙(The Dragon of Loowater, UVa 11292)
- Dragon of Loowater UVA - 11292
- UVa 11292 / POJ 3646 / HDU 1902 Dragon of Loowater (贪心)
- UVA - 11292 Dragon of Loowater 贪心
- Dragon of Loowater UVA - 11292 (水)
- UVa 11292 - Dragon of Loowater(贪心)
- UVA 11292 The dragon of Loowater勇士斗恶龙 11729 突击战 Commando War