uva 11292 Dragon of Loowater
来源:互联网 发布:手机画中画软件 编辑:程序博客网 时间:2024/06/08 00:54
题目:Dragon of Loowater
思路:贪心,每个头都让刚好能砍掉这个头的能力最差的人砍。
代码:
#include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<string>#include<map>#include<set>#include<queue>#include<deque>#include<algorithm>#include<cmath>using namespace std;int a[20005]={0},b[20005]={0};int n,m;int Do(){sort(a+1,a+n+1);sort(b+1,b+m+1);int j=1;int sum=0;for(int i=1;i<=n;i++){if(a[i]>b[j]) i--;else sum+=b[j];j++;}if(j>m+1) return -1;return sum;}int main() {while(~scanf("%d%d",&n,&m)&&n!=0){for(int i=1;i<=n;i++){int d;scanf("%d",&d);a[i]=d;}for(int i=1;i<=m;i++){int x;scanf("%d",&x);b[i]=x;}int ans=-1;if(n<=m){ans=Do();}if(ans==-1){printf("Loowater is doomed!\n");}else printf("%d\n",ans);}return 0;}
阅读全文
3 0
- uva --11292 --Dragon of Loowater
- UVa 11292 - Dragon of Loowater
- uva - 11292 - Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- uva 11292 - Dragon of Loowater
- Uva-11292-Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- UVA 11292 Dragon of Loowater
- uva 11292 - Dragon of Loowater
- UVA 11292 - Dragon of Loowater
- UVA 11292 Dragon of Loowater
- UVA 11292 Dragon of Loowater
- UVa 11292 Dragon of Loowater
- UVa 11292 Dragon of Loowater
- UVA 11292 Dragon of Loowater
- uva 11292 Dragon of Loowater
- UVA - 11292 Dragon of Loowater
- UVa 11292 Dragon of Loowater
- 两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同? 输入例子: 1999 2299 输出例子:7
- android平台视频直播,录制库
- 简单Hash
- WEB项目总结(三)dojo.js ajax应用实例
- CSS 边框
- uva 11292 Dragon of Loowater
- 数列有序!
- 寄存器
- c#怎样抓取html网页数据
- nginx负载均衡与动静分离
- Python网络爬虫与信息提取(二) BeautifulSoup库
- Android WebSocket实现即时通讯/推送
- Python windows 环境搭建
- [LeetCode]647. Palindromic Substrings