11292 - Dragon of Loowater(贪心)
来源:互联网 发布:涙は知っている 编辑:程序博客网 时间:2024/05/22 15:56
我的《训练指南》第一题,开始刷训练指南了,接下来会踏踏实实的独立刷题,远离题解。例题也尽量自己做。 刷题的内容大致就是lrj的两本书和另外的训练题。 其他的题库待我能力达到了再说吧。
该题很简单,排序、贪心即可。 很容易证明选厉害的骑士不如选差一点的好。
细节参见代码:
#include<bits/stdc++.h>using namespace std;const int maxn = 20000 + 5;int n,m,head[maxn],knight[maxn];int main() { while(~scanf("%d%d",&n,&m)) { if(!n && !m) break; for(int i=0;i<n;i++) scanf("%d",&head[i]); for(int i=0;i<m;i++) scanf("%d",&knight[i]); bool ok = true; int ans = 0; if(m < n) ok = false; else { ok = false; int rear = 0, cnt = 0; sort(head,head+n); sort(knight,knight+m); for(int i=0;i<n;i++) { while(rear < m) { if(knight[rear++]>=head[i]) { ans += knight[rear-1]; ++cnt; break; } } } if(cnt == n) ok = true; } if(ok) printf("%d\n",ans); else printf("Loowater is doomed!\n"); } return 0;}
0 0
- uva 11292 - Dragon of Loowater(贪心)
- uva - 11292 - Dragon of Loowater(贪心)
- 11292 - Dragon of Loowater(贪心)
- Dragon of Loowater(贪心)
- UVa 11292 The Dragon of Loowater (贪心)
- UVA 11292 Dragon of Loowater(贪心+排序)
- UVa 11292&HDU1902 The Dragon of Loowater (贪心)
- UVa 11292 - Dragon of Loowater(贪心)
- UVa 11292 - Dragon of Loowater[贪心]
- UVA - 11292 Dragon of Loowater (贪心)
- UVA 11292 DRAGON OF LOOWATER 【贪心】
- UVa Dragon of Loowater 11292 (贪心)
- 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 ( 排序 + 贪心 )
- UVA.11292 Dragon of Loowater (贪心)
- 加密 xmlrpc 客户端
- GridView、Repeater 列表截取字符用...代替
- eclipse的new server里tomcat7.0根本选不上解决方法
- textare的固定大小的设置
- QQ内置浏览器参数大全
- 11292 - Dragon of Loowater(贪心)
- Android GestureDetector手势识别与多点触控探究
- spring配置声明式事务--注解方式
- Installation error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
- 什么是MAC多播地址
- 03_常用UI控件
- Oracle数据库中 in与exists语句的区别
- 百度地图 导航开发 可能遇到问题
- 在Layout布局文件中添加控件ID,在Activity中findViewById找不到