C. Vasya and Basketball

题目连接:

http://codeforces.com/contest/493/problem/C

Description

Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the distance is larger than d meters, where d is some non-negative integer.

Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of d. Help him to do that.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — the number of throws of the first team. Then follow n integer numbers — the distances of throws ai (1 ≤ ai ≤ 2·109).

Then follows number m (1 ≤ m ≤ 2·105) — the number of the throws of the second team. Then follow m integer numbers — the distances of throws of bi (1 ≤ bi ≤ 2·109).

Output

Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction a - b is maximum. If there are several such scores, find the one in which number a is maximum.

Sample Input

3
1 2 3
2
5 6

Sample Output

9:6

Hint

题意

A队在n个距离位置投进了篮球,B队在m个位置。

现在让你来划3分线,然后使得A队分数减去B队分数最大。

题解:

暴力枚举三分线,肯定三分线就n+m+4种可能,都暴力枚举一边,然后对于每一个队伍,我二分找到有多少个二分球,和多少个三分球就好了

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+7;
int n,m;
int a[maxn],b[maxn];
int Ans=-1e9,Ans2,Ans3;
void update(int x,int y,int z)
{if(Ans<x)Ans=x,Ans2=y,Ans3=z;if(Ans==x&&y>Ans2)Ans=x,Ans2=y,Ans3=z;
}
void get(int x)
{int l=0,r=m,ans=1;while(l<=r){int mid=(l+r)/2;if(b[mid]<=x)ans=mid,l=mid+1;else r=mid-1;}int l2=0,r2=n,ans2=1;while(l2<=r2){int mid=(l2+r2)/2;if(a[mid]<=x)ans2=mid,l2=mid+1;else r2=mid-1;}update(ans2*2+(n-ans2)*3-ans*2-(m-ans)*3,ans2*2+(n-ans2)*3,ans*2+(m-ans)*3);
}
int main()
{scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);scanf("%d",&m);for(int i=1;i<=m;i++)scanf("%d",&b[i]);sort(a+1,a+1+n);sort(b+1,b+1+m);update(2*n-2*m,2*n,2*m);update(3*n-3*m,3*n,3*m);for(int i=1;i<=n;i++)get(a[i]);get(a[1]-1);get(a[n]+1);for(int i=1;i<=m;i++)get(b[i]);get(b[1]-1);get(b[m]+1);printf("%d:%d\n",Ans2,Ans3);
}

转载于:https://www.cnblogs.com/qscqesze/p/5844267.html

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分相关推荐

  1. Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟

    A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...

  2. Codeforces Round #512 (Div. 2 E. Vasya and Good Sequences 异或问题

    题目连接 题意: 给你n个数,每个数的二进制可以拆开,这个数拆开之后可以任意换0和1的位置,问有多少个l r区间 能满足异或和为0 做法:主要是看1的个数问题,由于0 1可以互换位置,那么我可以把1换 ...

  3. Codeforces Round #127 (Div. 1) E. Thoroughly Bureaucratic Organization 二分 数学

    E. Thoroughly Bureaucratic Organization 题目连接: http://www.codeforces.com/contest/201/problem/E Descri ...

  4. Codeforces Round #321 (Div. 2) B. Kefa and Company 二分

    B. Kefa and Company Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/580/pr ...

  5. Codeforces Round #409 (Div. 2) C Voltage Keepsake(二分)

    题意:有n(n<=100000)个机器...第i个机器最开始有bi(1<=bi <= 100000)个单位的电量,机器可以储存的电量没有上限,启动后每秒消耗ai(1<=ai&l ...

  6. Codeforces Round #686 (Div. 3) F. Array Partition(二分+线段树)

    题意:一段区间,让你分割成三段,第一段取max,第二段取min,第三段取max.问你怎么分割这个区间. 题解: 三个区间我们可以用两个点将一段区间分成三段区间. 二分:我们首先找这个题有关的单调性,我 ...

  7. Codeforces Round #540 (Div. 3) D. Coffee and Coursework 二分

    题解 题目大意,有若干杯咖啡,每杯咖啡有一个收益a[i],不限制每天喝多少杯,但是每天的第k杯收益会减少k-1,问总收益大于n的所需最少天数. 使用二分答案求解,每次喝肯定是挑剩余最大的去喝,chec ...

  8. Codeforces Round #481 (Div. 3) F. Mentors(思维+二分)

    有 n 个程序员,每个程序员都有他的技能分数,分数严格高的可以做分数低的程序员的老师,但是有 k 对人发生过矛盾,他们不能构成师生关系,问每个人最多可以做几个人的老师 开始想的是开一个数组从 i∈[1 ...

  9. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

最新文章

  1. 精简自己20%的代码
  2. Model-View-Presenter模式之 Step by Step
  3. c语言中虚函数和纯虚函数,虚函数和纯虚函数的区别是什么?
  4. 微型计算机中被处理信息称为,2011海南省计算机等级考试试题 二级C试题考资料...
  5. 侧边菜单栏 android-menudrawer
  6. kotlin编译失败_关于应用Kotlin后的编译速度问题
  7. Java 设置 JLabel 字体 颜色
  8. 韩立刚老师 -- 1、Linux 入门
  9. Origin 2019b 64Bit 软件绘制出图的坐标刻度老是消失怎么解决
  10. php奖学金系统,java/php/net/pythont奖助学金管理系统设计
  11. 关于js的match用法
  12. java后端getmonth_Java YearMonth getMonth()用法及代码示例
  13. MySQL运行机制原理架构
  14. github访问不进去,浏览器证书不安全,访问失败,证书失效,证书颁发者为VMware,谷歌浏览器小bug
  15. 1.13 golang中的Map
  16. win10多显示器设置只有主显示屏显示任务栏
  17. 计算机组成与结构(Ⅰ)
  18. 人体冷冻技术科学家称四十年内实现冷冻后复活,实现起死回生和长生不死
  19. MySQL数据表字段类型有哪些
  20. 远程连接linux配置文件,Linux远程连接介绍及相关配置

热门文章

  1. javascript感叹号1_「翻译」JavaScript的可视化学习之三:作用域(链)
  2. html获取xml分页,JavaScript操作XML实例代码(获取新闻标题并分页,并分页)
  3. vba oracle 01019,Oracle 客户端连接时报ORA-01019错误总结
  4. 一看就会的OSPF路由协议综合实验
  5. 如何在后台运行 Linux 命令
  6. vuex状态持久化_Vuex数据状态持久化
  7. android service框架,Android应用框架之Service
  8. h5手机端浏览器机制_H5测试介绍
  9. apt包管理 Android,apt软件包管理学习(示例代码)
  10. python 压缩文件 调用7z_Python:如何从Python压缩的7z文件中读取一行?