计算机学院大学生程序设计竞赛(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 ...
随机推荐
- angular跨域访问的问题
CORS跨域资源共享 跨域资源共享(CORS )是一种网络浏览器的技术规范,它为Web服务器定义了一种方式,允许网页从不同的域访问其资源. Form responseHeaders = (Form) ...
- Inno Setup入门(二十)——Inno Setup类参考(6)
存储框 存储框也是典型的窗口可视化组件,同编辑框类似,可以输入.显示文本,但是和编辑框不同的是,编辑框只能编辑.显示单行文本,而存储框则可以对多行文本进行操作.存储框的类定义如下:< xmlna ...
- C# 将字符串转为ऩ这种的 html实体编码
1.字符串转为html实体编码 private string GetHtmlEntities(string str) { string r = string.Empty; ; i < str.L ...
- asp发邮件控件
<% Set jmail = Server.CreateObject("JMAIL.SMTPMail") ’创建一个JMAIL对象 jmail.silent = true ’ ...
- block 的演练和使用
概念 block 是 C 语言的 是一种数据类型,可以当作参数传递 是一组预先准备好的代码,在需要的时候执行 动画 block 回顾 self.demoView.center = CGPointMak ...
- Creating your own header file in C
终于跑起来了,含自定义 include .h 的c语言程序,超开心呀! header files contain prototypes for functions you define in a .c ...
- ubuntu 上下载PHP的源代码
参考: https://vpsineu.com/blog/how-to-build-and-install-php-5-6-9-from-source-on-ubuntu-14-04-vps/ 直接 ...
- 转 oracle 如何停下oracle 服务
设置SET ORACLE_SID=ORCL ORCL--实例名称 --停止oracle实例服务 C:\Users\Administrator>net stop oracleserviceORCl ...
- 事务(JDBC、Hibernate、Spring)
如果不用spring管理事务,我们自己写代码来操作事务.那么这个代码怎么写要看底层怎么访问数据库了. 当采用原生JDBC访问数据库时,操作事务需要使用java.sql.Connection的API.开 ...
- POJ 1365 Prime Land(整数拆分)
题意:感觉题意不太好懂,题目并不难,就是给一些p和e,p是素数,e是指数,然后把这个数求出来,设为x,然后让我们逆过程输出x-1的素数拆分形式,形式与输入保持一致. 思路:素数打表以后正常拆分即可. ...