hdu——3661(贪心)
来源:互联网 发布:javascript算术运算符 编辑:程序博客网 时间:2024/05/17 01:14
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3661
原理解析:http://www.cnblogs.com/kuangbin/archive/2011/07/28/2119439.html
转载代码:
#include<stdio.h>#include<algorithm>using namespace std;const int MAXN=1001;int a[MAXN];int b[MAXN];bool cmp(int a,int b){ return a>b;} int main(){ int n,t; int sum; while(scanf("%d%d",&n,&t)!=EOF) { int i; for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) scanf("%d",&b[i]); sort(a,a+n); sort(b,b+n,cmp); sum=0; for(i=0;i<n;i++) { if(a[i]+b[i]-t>0) sum+=a[i]+b[i]-t; } printf("%d\n",sum); } return 0; }
- hdu——3661(贪心)
- 贪心—save-hdu
- HDU2111——Saving HDU(贪心)
- HDU 3661-Assignments(贪心)
- 贪心——HDU 1009
- 贪心——HDU 5360
- 贪心——HDU 4572
- 贪心——HDU 4415
- HDU 4925 ——Apple Tree(贪心)
- HDU——1789Doing Homework again(贪心)
- HDU——1257最少拦截系统(贪心)
- 贪心+树剖(假)—— HDU 5242
- 贪心-hdu-3661-Assignments
- hdu 3661 Assignments 贪心
- hdu 3661 Assignments【贪心】
- HDU-3661(贪心)
- 初识贪心!——hdu 2037
- 水一道贪心——hdu 1009
- 系统设计七(百度笔试题)
- 计算机方向的研究生
- Android 内存监测工具 DDMS --> Heap
- DataSnap服务器如何得到客户端的IP和端口
- 电压转电流电路
- hdu——3661(贪心)
- c++学习笔记一
- DataSnap-TCP keepAlive和KeepAliveInterval参数详解
- LoadRunner测试中自动关联出现问题的解决方法
- 时间工具类(DateUtil)
- 家乡的小河
- c++学习笔记二
- DataSnap-建立稳定服务程序之TCP心跳包的使用
- c++学习笔记三