题意:

  给n把枪,m个怪兽,每把枪可消灭1怪兽,并获得能量=枪的攻击力-怪兽的防御力。求如何射杀能获得最多能量?(不必杀光)

思路:

  用最大攻击力的枪杀防御力最小的怪兽明显可获得最大能量。如果每把枪都去射杀刚好1点能量都拿不到的怪物,那简直等于把枪全丢掉。

 //#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#define LL long long
#define pii pair<int,int>
#define INF 0x7f7f7f7f
using namespace std;
const int N=+;
int a[N], b[N]; int main()
{
//freopen("input.txt", "r", stdin);
int t, n, m;
cin>>t;
while(t--)
{
scanf("%d%d",&n, &m); for(int i=; i<n; i++) scanf("%d",&a[i]);
for(int i=; i<m; i++) scanf("%d",&b[i]); sort(a, a+n);
sort(b, b+m);
int bb=, aa=n-;
LL ans=;
while(aa>= && bb<m && a[aa]>b[bb])
{
ans+=a[aa]-b[bb];
bb++;
aa--;
}
printf("%lld\n",ans);
} return ;
}

AC代码

HDU Senior's Gun (水题)的更多相关文章

  1. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  2. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

  3. HDU 4813 Hard Code 水题

    Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  4. HDU 4593 H - Robot 水题

    H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  5. HDOJ/HDU 2560 Buildings(嗯~水题)

    Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...

  6. HDOJ(HDU) 1859 最小长方形(水题、、)

    Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...

  7. HDU - 1716 排列2 水题

    排列2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  8. HDU—2021-发工资咯(水题,有点贪心的思想)

    作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵  但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每 ...

  9. hdu 5753 Permutation Bo 水题

    Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

随机推荐

  1. 1027 Colors in Mars (20)

    #include <stdio.h> #include <map> using namespace std; int main() { int R,G,B,i; map< ...

  2. Can’t create handler inside thread that has not called Looper.prepare()

    1)在Android 2.3以前,为防止ANR(Application Not Responding),Google是不赞成将网络连接等一系列耗时操作直接放到应用主线程进行的,推荐将这类操作放在子线程 ...

  3. 编译升级php

    http://www.linux-centos.com/2014/11/16/%E7%BC%96%E8%AF%91%E5%8D%87%E7%BA%A7%E4%BB%8Ephp5-2-17%E5%88% ...

  4. random note

    今天才慢慢意识到,什么才是学习,(以思考解决问题为驱动),埋头刷分只是方法,不是目的和原动力. 既然准备读研,就要慢慢去了解研究生的生活学习方式是什么样的,涉及到哪些方面. 读研之前要选好方向,但是现 ...

  5. struts2的namespace

    struts2 的命名空间action里的name是个无关紧要的东西,namespace为‘/’表示所有 为‘/名字’,不管怎么访问只要名称空间些对了就不会错,/时你的请求地址可以直接写**Actio ...

  6. 隐藏和显示效果js动画

    <div id='ctt' style='margin-left: 50px; color: white'>             <input type="button ...

  7. C# - dynamic 类型

    C#4引入dynamic关键字,定义变量时,可以不初始化它的值. dynamic类型仅在编译期间存在,在运行期间会被System.Object类型替代. dynamic myDynamicVar; m ...

  8. Maven系列--"maven-compiler-plugin"的使用、Maven之Surefire插件

    一."maven-compiler-plugin"的使用 http://my.oschina.net/poorzerg/blog/206856 二.Maven之Surefire插件 ...

  9. Competing in a data science contest without reading the data

    Competing in a data science contest without reading the data Machine learning competitions have beco ...

  10. pythn BeautifulSoup

    http://rsj217.diandian.com/post/2012-11-01/40041235132 Beautiful Soup 是用 Python 写的一个 HTML/XML 的解析器,它 ...