Codeforces 439D Devu and his Brother 三分
来源:互联网 发布:软件连不上网络 编辑:程序博客网 时间:2024/05/17 01:51
题目链接:点击打开链接
= - =以前的三分姿势不正确居然没有被卡掉,,,太逗。。
#include<iostream>#include<string>#include<algorithm>#include<cstdlib>#include<cstdio>#include<set>#include<map>#include<vector>#include<cstring>#include<stack>#include<cmath>#include<queue>using namespace std;#define M 200004#define N 100040#define L(x) (x<<1)#define R(x) (x<<1|1)#define Mid(x,y) ((x+y)>>1)#define ll __int64#define Sum(x) tree[x].sum#define Mod(x) tree[x].mod#define inf 1000000000ll n,m;ll a[N],b[N];ll ok(ll x){ll ans = 0;for(ll i = 1; i <= n; i++)if(x>a[i])ans+=(x-a[i]);for(ll i = 1; i <= m; i++)if(x<b[i])ans+=(b[i]-x);return ans;}int main(){ll i,j,u,v;while(~scanf("%I64d %I64d",&n,&m)){ll minn = inf, maxx = 0;for(i=1;i<=n;i++)scanf("%I64d",&a[i]), minn = min(minn,a[i]);for(i=1;i<=m;i++)scanf("%I64d",&b[i]), maxx = max(maxx,b[i]);if(minn>=maxx){puts("0");continue;}ll ans = inf;ll l = minn, r = maxx;ans = min(ok(l),ok(r));while(l<r){ll mid1 = (l+r)/2, mid2 = (mid1+r)/2;ll tmp1 = ok(mid1), tmp2 = ok(mid2);if(tmp1>tmp2)l = mid1;else r = mid2;ans = min(ans, min(tmp1, tmp2));}printf("%I64d\n",ans);}return 0;}/*2 22 33 53 21 2 33 43 24 5 61 2*/
0 0
- Codeforces 439D Devu and his Brother 三分
- Codeforces 439D Devu and his Brother【思维+三分查找】
- Codeforces 439D Devu and his Brother
- Codeforces 439D Devu and his Brother
- CodeForces 439D Devu and his Brother
- Codeforecs 439D Devu and his Brother 三分
- Codeforces 439D Devu and his Brother(排序)
- 439 D. Devu and his Brother
- CF 439D Devu and his Brother
- Codeforces Round #251 (Div. 2) D. Devu and his Brother
- Codeforces Round#251(Div 2)D Devu and his Brother
- Codeforces Round #251 (Div. 2) D Devu and his Brother
- Codeforces Round #251 (Div. 2)-D. Devu and his Brother
- Codeforces Round #251 Div2D 439D Devu and his Brother 二分查找STL
- Codeforces Round #251 (Div. 2) 439D Devu and his Brother(脑洞)
- Codeforces Round #251(Div. 2) 439D. Devu and his Brother 枚举
- CF 439D(251D题)Devu and his Brother
- codeforces 66D D. Petya and His Friends( 数论+构造)
- poj3176 Cow Bowling
- vim配置
- 黑马程序员_Java当中异常处理机制2
- ubuntu12.04解决中文文件名乱码
- 15.1工资数据的输入(二)
- Codeforces 439D Devu and his Brother 三分
- Sting&&StringBuffer&StringBuilder三者区别
- 同机上进行 duplicate
- vim的查找字符串
- 使用Eclipse搭建Android的开发环境
- 双工位机器人 焊接夹具注意事项 o(╯□╰)o
- java 获取相关日期
- extern的使用
- 第15周 项目三 oop版电子词典