UVA_11292_Dragon of Loowater
来源:互联网 发布:vcr制作软件破解 编辑:程序博客网 时间:2024/06/03 17:53
#include<iostream>#include<sstream>#include<string>#include<vector>#include<list>#include<set>#include<map>#include<stack>#include<queue>#include<algorithm>#pragma warning(disable:4996)#include<cstdio>#include<cstdlib>using std::cin;using std::cout;using std::endl;using std::stringstream;using std::string;using std::vector;using std::list;using std::pair;using std::set;using std::multiset;using std::map;using std::multimap;using std::stack;using std::queue;using std::priority_queue;int main(){//freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n, m;while (cin >> n >> m && (n + m)){vector<int>dragon(n), knight(m);for (int i = 0; i < n; i++){cin >> dragon[i];}for (int i = 0; i < m; i++){cin >> knight[i];}if (n > m)//如果龙的数量大于骑士的数量,显然屠龙失败{cout << "Loowater is doomed!" << endl;continue;}std::sort(dragon.begin(), dragon.end());std::sort(knight.begin(), knight.end());int cost = 0, killed = 0;for (int i = 0,j=0;i<n&&j<m;j++){if (dragon[i] <= knight[j])//如果龙的血量小于等于骑士的战斗力,即屠龙成功{cost += knight[j];i++;//跳到下一条龙killed++;//屠龙数+1}}//如果屠龙数量==龙的数量,输出已屠龙的数量if (killed == n){cout << cost << endl;}else{cout << "Loowater is doomed!" << endl;}}return 0;}
0 0
- UVA_11292_Dragon of Loowater
- uva11292 Dragon of Loowater
- UVA11292:Dragon of Loowater
- 11292 - Dragon of Loowater
- UVa11292 Dragon of Loowater
- uva11292 - Dragon of Loowater
- UVA11292-Dragon of Loowater
- UVa11292 - Dragon of Loowater
- The Dragon of Loowater
- 11292 - Dragon of Loowater
- Dragon of Loowater
- uva11292 Dragon of Loowater
- The Dragon of Loowater
- hdu1902The Dragon of Loowater
- The Dragon of Loowater
- The Dragon of Loowater
- 11292 - Dragon of Loowater
- Dragon of Loowater
- ceilometer + gnocchi + aodh集成(005) ---- gnocchi集成influxdb
- Linux 回收用户空间资源
- 【poj】-1611-The Suspects(找到需要的根,再找所有根为此的树枝)
- 第89讲:Spark Streaming on Kafka解析和安装实战
- CRichEditCtrl使用大全
- UVA_11292_Dragon of Loowater
- MIFARE DESFire卡介绍
- 文件管理 - 1
- 可移植的Android异步任务AsyncTask类
- error C2088: '-' : illegal for union
- 笔记二:计数排序、选择排序、冒泡排序、插入排序
- inf文件的编写
- C/C++复习:分数减法(结构体)
- HDU 1664 放苹果