hdu-5281 Senior's Gun*
来源:互联网 发布:木马编程入门 编辑:程序博客网 时间:2024/05/16 18:32
题意:有n把枪m个怪兽,枪(a[n])和怪兽(b[m])都有一个值,每把枪可打死一只怪兽,枪打死怪兽可获得a-b积分,求最后最多积分。
思路:最后的方案一定是攻击力最强的k把枪消灭了防御最弱的k只怪物。
#include<iostream>#include<stdio.h>#include<math.h>#include <string>#include<string.h>#include<map>#include<set>#include<algorithm>#include<stdlib.h>using namespace std;#define eps 1e-13#define inf 0x3f3f3f3f#define rd(x) scanf("%d",&x)#define rd2(x,y) scanf("%d%d",&x,&y)#define ll long long int#define mod 998244353bool cmp(int a,int b){ return a>b;}int a[100005],b[100005],T;int main(){ rd(T); int n,m; while(T--) { rd2(n,m); for(int i=0;i<n;i++) rd(a[i]); for(int i=0;i<m;i++) rd(b[i]); sort(a,a+n,cmp); sort(b,b+m); ll res=0; for(int i=0;i<n,i<m;i++) { if(a[i]>b[i]) res+=(ll)(a[i]-b[i]); else break; } printf("%I64d\n",res); } return 0;}
0 0
- hdu 5281 Senior's Gun
- HDU 5281 Senior's Gun
- hdu 5281 Senior's Gun
- hdu-5281 Senior's Gun*
- HDU 5281 Senior's Gun
- HDU 5281 Senior's Gun
- HDU 5281 Senior's Gun 杀怪
- hdu 5281 Senior's Gun(贪心)
- HDU——5281 Senior's Gun
- HDU 5281 Senior's Gun 贪心
- HDU 5281 BestCoder Round #47 1002:Senior's Gun
- hdu 5281 Senior's Gun(贪心)(思维)
- HDU 5281 Senior's Gun——BestCoder Round #47(贪心)
- Bestcoder #47 B Senior's Gun
- HDOJ5281 Senior's Gun(贪心思想)
- Senior's Gun-------(BestCoder Round #47)
- HDU 5280 Senior's Array
- hdu 5280 Senior's Array
- Android Studio 1.1.0 导入eclipse android project
- UDE大全
- 右拐角矩阵
- 自定义View----点击滑动选择字母列表
- Python3 - 时间处理与定时任务
- hdu-5281 Senior's Gun*
- Android学习博客资源收藏
- Autolayout
- Callable接口和Runnable接口
- Unity3d 刚体碰撞器
- MongoDB集群之分片
- price_shop升级制作
- 1150_整除的尾数
- android TextView如何纵向显示文字