Uva11292
来源:互联网 发布:dpp软件怎么调色 编辑:程序博客网 时间:2024/05/17 04:32
#include <cstdio>#include <algorithm>using namespace std;int main(){int n,m;//龙头的数量和骑士的数量//int sum=0;第一次出错是因为我把sum的定义放在了这里,以至于每组数据使用的sum都是前一组数据留下来的未清理的数据while(scanf("%d%d",&n,&m)==2&&n&&m){int sum=0;//记录最后花费的能力值int *head=new int[n];//记录每个头的直径int *energy=new int[m];//记录每个勇士的能力值//读入n个龙头的直径for(int i=0;i<n;i++){scanf("%d",&head[i]);}//读入m个勇士的能力值for(int i=0;i<m;i++){scanf("%d",&energy[i]);}sort(head,head+n);sort(energy,energy+m);int i,j;for(i=0,j=0;i<n&&j<m;){if(head[i]<=energy[j]){sum+=energy[j];i++;j++;}elsej++;}if(i==n)printf("%d\n",sum);elseprintf("Loowater is doomed!\n");}return 0;}
0 0
- UVA11292
- UVa11292
- UVa11292
- uva11292
- uva11292
- UVa11292
- Uva11292
- UVA11292
- UVa11292
- UVA11292
- UVa11292
- UVa11292
- UVA11292杀怪
- uva11292--贪心
- uva11292 Dragon of Loowater
- UVA11292:Dragon of Loowater
- UVa11292 Dragon of Loowater
- uva11292 - Dragon of Loowater
- c++运算符重载
- 创想
- java.lang
- 唉卧槽,9个月过去了
- C++中引用(&)的用法
- Uva11292
- 读视频时,帧率的设置
- "".indexOf()的作用,以及结果标识 1、0、-1
- java读取properties文件
- kcotSlleSdnayuBtoTimetseB.121
- linux怎样判断当前登录的用户是从console登录还是telnet登录的
- Kconfig、Kbuild Makefile
- 从django的中间件直接返回请求
- 37.You issued the following command to drop the PRODUCTS table: