uva11292
来源:互联网 发布:马尔可夫矩阵怎么算 编辑:程序博客网 时间:2024/06/08 14:58
一次就ac的水题,纪念一下,今天听到小公主说,做专题提高才快,很有道理啊!~以后思维题,算法题都要做!
#include<cstdio>#include<algorithm>#include<cstdlib>#include<cstring>#include<iostream>using namespace std;int head[20005],can[20005];int main(){ int n,m; while(scanf("%d %d",&n,&m)&&n&&m) { for(int i=0;i<n;i++) { scanf("%d",&head[i]); } for(int i=0;i<m;i++) { scanf("%d",&can[i]); } sort(head,head+n); sort(can,can+m); if(n>m) { printf("Loowater is doomed!\n"); continue; } int flag=1; for(int i=n-1,j=m-1;i>=0;i--,j--) { if(head[i]>can[j]) { flag=0; break; } } if(!flag) { printf("Loowater is doomed!\n"); continue; } else { int sum=0; for(int i=0,j=0;i<n;) { if(can[j]>=head[i]) { sum+=can[j]; i++,j++; } else j++; } printf("%d\n",sum); } }}
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
- Xilinx FPGA 学习笔记一-chipscope 无法观察信号 BUFG
- HTML5 - frameset框架集
- SQL SERVER 批量数据插入方法
- Lua_速度动作
- ali
- uva11292
- Lua_函数回调
- 第一次使用ejb
- php五大运行模式CGI,FAST-CGI,CLI,ISAPI,APACHE模式浅谈
- Apache虚拟主机的六种配置方法
- Lua_特效动作
- 11300 - Spreading the Wealth
- 在apache下配置浏览器缓存
- C++学习笔记(一)