题目

//参考了网上的代码

注意答案可能超过32位

//要达成目标,就是要所有数列a的都比数列b的要小或者等于
//然后,要使最小的要和最大的一样大,就要移动(大-小)步,
//要使较小的要和较大的一样大,也是要移动(较大-较小)步
//然后都加在一起就好了 #include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll long long
int cmp(ll x,ll y)
{
return x>y;
}
ll a[],b[];
int main()
{
ll n,m;
cin >> n>> m;
for(int i=;i<n;i++)
cin >> a[i];
for(int i=;i<m;i++)
cin >> b[i];
sort(a,a+n);
sort(b,b+m,cmp);
if(n>m)n=m;
ll ans=;
for(int i=;i<n;i++)
if(a[i]<b[i])
ans+=(b[i]-a[i]);
cout << ans <<endl;
return ;
}

codeforces 439D Devu and Partitioning of the Array(有深度的模拟)的更多相关文章

  1. Codeforces 439C Devu and Partitioning of the Array(模拟)

    题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...

  2. codeforces 439C Devu and Partitioning of the Array(烦死人的多情况的模拟)

    题目 //这是一道有n多情况的烦死人的让我错了n遍的模拟题 #include<iostream> #include<algorithm> #include<stdio.h ...

  3. codeforces C. Devu and Partitioning of the Array

    题意:给你n个数,然后分成k部分,每一个部分的和为偶数的有p个,奇数的有k-p个,如果可以划分,输出其中的一种,不可以输出NO; 思路:先输出k-p-1个奇数,再输出p-1个偶数,剩余的在进行构造.  ...

  4. codeforces 251 div2 C. Devu and Partitioning of the Array 模拟

    C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...

  5. CodeForce 439C Devu and Partitioning of the Array(模拟)

     Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  6. CF 439C Devu and Partitioning of the Array

    题目链接: 传送门 Devu and Partitioning of the Array time limit per test:1 second     memory limit per test: ...

  7. CF 439C(251C题)Devu and Partitioning of the Array

    Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  8. Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Array

    注意p的边界情况,p为0,或者 p为k 奇数+偶数 = 奇数 奇数+奇数 = 偶数 #include <iostream> #include <vector> #include ...

  9. Codeforces 439D Devu and his Brother 三分

    题目链接:点击打开链接 = - =曾经的三分姿势不对竟然没有被卡掉,,,太逗.. #include<iostream> #include<string> #include< ...

随机推荐

  1. JQuery ----文档处理

    1.append(content|fn) 概述 向每个匹配的元素内部追加内容. 这个操作与对指定的元素执行appendChild方法,将它们添加到文档中的情况类似. 2.appendTo(conten ...

  2. automapper的简单用法

    AutoMapper对象转换方面(Object-Object Mapping)对象映射工具,实现对象和对象之间的转化.主要应用在项目的dto,model,entity或viewmodel之间转换,其实 ...

  3. db2查询锁表

    --查询锁表情况,可以获取哪个表被锁,其中agent_id为哪个DB2进程锁了表(db2inst1用户下) select * from sysibmadm.LOCKS_HELD with ur; -- ...

  4. Object C学习笔记2-NSLog 格式化输出数据

    1 . 几种常用类型变量声明 int i =10; BOOL isShow=YES; BOOL isShow=1; float f = 3.1415926; char a =120; NSString ...

  5. mac下163企业邮箱客户端的配置

    一 添加账户       添加账户->添加其他邮件账户->输入电子邮件地址和密码.(全名随意起).   二 收件服务器和发件服务器的设置       收件服务器:pop.qiye.163. ...

  6. 条款7:为多态基类声明virtual析构函数

    C++明确指出:当派生类对象是由一个基类指针释放的,而基类中的析构函数不是虚函数,那么结果是未定义的.其实我们执行时其结果就是:只调用最上层基类的析构函数,派生类及其中间基类的析构函数得不到调用. # ...

  7. springboot快速搭建

    环境 spring-boot-starter-parent 是一个特殊的starter,它提供了有用的Maven默认设置.同时,它也提供了一个 dependency-management 节点,这样对 ...

  8. OpenCV检测人脸实例代码

    下面是使用OpenCV通过在硬盘中读入图像来对其进行Haar人脸检测的代码. //包含头文件 #include <opencv2/core/core.hpp> #include " ...

  9. To add private variable to this Javascript literal object

    You can use number as function/variable name, the numberic name can't be accessed from parent scope, ...

  10. 几种常见的排序方法(C语言实现)

    #include <stdio.h> #include <stdlib.h> #include <Windows.h> //直接插入排序 void InsertSo ...