题目

//参考了网上的代码

注意答案可能超过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. angularjs2 学习笔记(二) 组件

    angular2 组件 首先了解angular2 组件的含义 angular2的应用就是一系列组件的集合 我们需要创建可复用的组件供多个组件重复使用 组件是嵌套的,实际应用中组件是相互嵌套使用的 组件 ...

  2. bat完美关机命令

    @echo off title OLIVER-COMPUTER mode con cols= lines= color 0d shutdown /a >nul >nul ver > ...

  3. [Environment Build] Win10下Appach配置

    1. Apache下载,登录http://httpd.apache.org/download.cgi,选择Files for Microsoft Windows, 有以下几个选择, 我选择的是Apac ...

  4. 微信扫码支付asp.net(C#)实现步骤

    支付提交页面: [HttpPost] public ActionResult index(decimal amount) { //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯 ...

  5. json转换对象

    JSON.parse(jsonstr); //可以将json字符串转换成json对象 JSON.stringify(jsonobj); //可以将json对象转换成json对符串

  6. 学习IOS需要知道的事

    什么是iOS iOS是一款由苹果公司开发的操作系统(OS是Operating System的简称),就像平时在电脑上用的Windows XP.Windows 7,都是操作系统 那什么是操作系统呢?操作 ...

  7. maven属性

    Maven内置了三大特性:属性.Profile和资源过滤来支持构建的灵活性. 内置属性:主要有两个常用内置属性 ${basedir}表示项目根目录,即包含pom.xml文件的目录 ${version} ...

  8. android Service Activity交互之传递复杂数据类型的远程服务

    远程服务往往不只是传递java基本数据类型.这时需要注意android的一些限制和规定: android支持String和CharSequence 如果需要在aidl中使用其他aidl接口类型,需要i ...

  9. 莫名戳中"肋骨"的文章

    1 起初,我们总是会害怕,害怕不能得到自己渴望的物质生活,害怕遇不到那个好好爱自己的人,害怕失去青春也换不回事业上的进步,害怕会做下一个让自己悔恨的决定,可这一路,我们就是这样踩着自己的害怕和悔恨走来 ...

  10. Understanding Service Types

    Last update: June 2014. I have partially rewritten this article to provide more technical details an ...