水题,排序遍历即可

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4.  
  5. using namespace std;
  6.  
  7. const int maxn = ;
  8. int drag[maxn], kn[maxn];
  9. int main()
  10. {
  11. int n, m, cost;
  12. while (cin >> n >> m) {
  13. if(n == && m == )break;
  14. for (int i = ;i < n;i++)cin >> drag[i];
  15. for (int i = ;i < m;i++)cin >> kn[i];
  16. sort(drag, drag + n);
  17. sort(kn, kn + m);
  18. int cur = ;
  19. cost = ;
  20. for (int i = ;i < m;i++) {
  21. if (kn[i] >= drag[cur]) {
  22. cost += kn[i];
  23. if (++cur == n)break;
  24. }
  25. }
  26. if (cur < n)cout << "Loowater is doomed!" << endl;
  27. else cout << cost << endl;
  28. }
  29. return ;
  30. }

uva11292 Dragon of Loowater的更多相关文章

  1. 勇者斗恶龙UVa11292 - Dragon of Loowater

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=s ...

  2. uva11292 Dragon of Loowater(排序后贪心)

    #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...

  3. uva-----11292 The Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  4. The Dragon of Loowater

      The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into ...

  5. uva 11292 Dragon of Loowater (勇者斗恶龙)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  6. UVA它11292 - Dragon of Loowater

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  7. UVA 11292 Dragon of Loowater(简单贪心)

    Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance tur ...

  8. Dragon of Loowater

    option=com_onlinejudge&Itemid=8&page=show_problem&problem=2267" style="color:b ...

  9. 贪心/思维题 UVA 11292 The Dragon of Loowater

    题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...

随机推荐

  1. iOS_Swift初识之使用三种回调方式自定义Button

    最近在学习Swift ,发现青玉伏案大神早期用OC写的一篇博客--IOS开发之自定义Button(集成三种回调模式)  很适合用来熟悉Swift的回调方式,于是我就用Swift翻版了一下,具体实现原理 ...

  2. HTML 图像显示

    HTML 图像显示:图像标签:<img>,源属性:Src<img>是空标签,没有闭合标签,它只包含属性:显示图像时需要调用源属性src:src的值是图像的地址:语法:<i ...

  3. js调用页面打印

    ----------------------调用页面打印-------------------------------- <body> <div id="divPrint& ...

  4. 怎么用BarTender的格式刷

    BarTender的新格式刷使您能够轻松地在模板上的多个对象之间共享格式.您可以在单个模板中以及在多个BarTender模板和文档之间复制对象样式.下面小编给大家来讲讲BarTender格式刷这一可用 ...

  5. Java中引用类型变量,对象,值类型,值传递,引用传递 区别与定义

    一.Java中什么叫做引用类型变量?引用:就是按内存地址查询       比如:String s = new String();这个其实是在栈内存里分配一块内存空间为s,在堆内存里new了一个Stri ...

  6. eclipse简单使用

    1.10个快捷键: 1. ctrl+shift+r:打开资源       Control-Shift-T: 打开类型(Open type) Control-Shift-F: CodeàJavaàPre ...

  7. 手机网页调试利器: Chrome

    新开发的网页需要在手机或是模拟机上运行测试, 可以借助 Chrome提供的手机网页预览程序进行简单调试.查看 制作的网页是否能够适合各种手机型号使用. 下面所以下如何使用Chrome调试多类型手机网页 ...

  8. Redis执行Lua脚本的情况

    第一个测试: 往Redis里面存入1000个Hash,每个Hash里面有100个元素(Key 0-99,值是Key^2). PHP代码,执行33s左右 <?php $redis = new Re ...

  9. 从click事件理解DOM事件流

    事件流是用来解释页面上的不同元素接受一个事件的顺序,首先要明确两点: 1.一个事件的影响元素可能不止一个(同心圆理论),但目标元素只有一个. 2.如果这些元素都绑定了相同名称的事件函数,我们怎么知道这 ...

  10. NodeJs:module.filename、__filename、__dirname、process.cwd()和require.main.filename

    转载于: http://blog.csdn.net/bugknightyyp/article/details/17999473 module.filename:开发期间,该行代码所在的文件. __fi ...