计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle
#include<cstdio>
#include<algorithm>
using namespace std;
using namespace std; const int maxn=+;
int a[maxn],b[maxn]; int main()
{
int n,m;
while(scanf("%d %d",&n,&m)!=EOF)
{
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+);
b[]=-;
int now=m,ans=;
for(int i=n; i>=; i--)
{
while(abs(a[i]-b[now])>=abs(a[i]-b[now-])) now--;
ans=ans+abs(a[i]-b[now]);
}
printf("%d\n",ans);
}
return ;
}
计算机学院大学生程序设计竞赛(2015’12) 1003 The collector’s puzzle的更多相关文章
- hdu 计算机学院大学生程序设计竞赛(2015’11)
搬砖 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...
- 计算机学院大学生程序设计竞赛(2015’11)1005 ACM组队安排
1005 ACM组队安排 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
Study Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
Polygon Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
The Country List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words
#include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...
- 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using ...
- 计算机学院大学生程序设计竞赛(2015’12) 1006 01 Matrix
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> ...
- 计算机学院大学生程序设计竞赛(2015’12) 1004 Happy Value
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include ...
随机推荐
- javascript模糊查询一个数组
/* * 模糊查询一个数组 */ com.ty.repairtech.JsonOperation.searchList = function(str, container) { var newList ...
- Linux入门学习教程:虚拟机体验之KVM篇
本文中可以学习到的命令: 1. aptitude 是apt-get 不会产生垃圾的版本 2. dpkg -L virtualbox 显示属于该包的文件 lsmod | grep kvmfi ...
- JSP基础语法--跳转指令 jsp:forward page
带参数的跳转指令: <jsp:forward page="{路径|<%=表达式%>}"/> <jsp:param name="参数名称&qu ...
- Hibernate关于openSession和getCurrentSession的理解
来源(转载):http://blog.csdn.net/woshisap/article/details/7024482 1:getCurrentSession会把Session和当前的线程关联起来, ...
- vbscript语句
'vbscript语句Call'[call] name [argumentlist]'把控制转移到函数或子程序.当调用函数或子程序时,Call是可写可不写的.但是如果你用了Call,那么argumen ...
- 要想提高PHP的编程效率,你必须遵守的原则
用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说 ...
- Spring Boot 系列教程11-html页面解析-jsoup
需求 需要对一个页面进行数据抓取,并导出doc文档 html解析器 jsoup 可直接解析某个URL地址.HTML文本内容.它提供了一套非常省力的API,可通过DOM,CSS以及类似于JQuery的操 ...
- 从市场运营角度谈Uber中国的第一批用户是怎么来的
声明:这篇文章是从http://www.010lm.com/redian/2016/0312/1206875.html转来的,分享给大家. 1)首先告诉用户Uber是做什么的?即培养用户品牌意识. 我 ...
- Swift -> Let & Var 背后编程模式 探讨
简介 Swift中有两种声明“变量”的方式,这两种方式分别使用let和var这两个关键字.这应该是借鉴了Scala,因为它们和Scala的val和var有相同的作用.let被用于声明不变量,var被用 ...
- Viewpager实现图片轮播
//-------------主布局文件------------------------------------- <LinearLayout xmlns:android="http: ...