C. Vasya and Basketball
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 - bis maximum. If there are several such scores, find the one in which number a is maximum.

Examples
input
3
1 2 3
2
5 6
output
9:6
input
5
6 7 8 9 10
5
1 2 3 4 5
output
15:10
思路:我怎么zz的写了个二分;
   n*3-n小于等于d的个数-m*2-m大于d的个数最大;
   显然需要求n小于等于d的个数+m大于d的个数最小;
   我是暴力二分,排个序好像可以把二分取消了;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=2e5+,M=4e6+,inf=1e9+,mod=1e9+;
const ll INF=1e18+;
int a[N],b[N],sa,sb;
int l[N<<];
int flag,n,m;
int check(int x)
{
int pos1=upper_bound(a,a+n,x)-a;
int pos2=upper_bound(b,b+m,x)-b;
pos2=m-pos2;
return pos1+pos2;
}
int main()
{
flag=;
scanf("%d",&n);
for(int i=;i<n;i++)
scanf("%d",&a[i]),l[flag++]=a[i];
scanf("%d",&m);
for(int i=;i<m;i++)
scanf("%d",&b[i]),l[flag++]=b[i];
sort(a,a+n);
sort(b,b+m);
l[flag++]=;
l[flag++]=2e9+;
sort(l,l+flag);
flag=unique(l,l+flag)-l;
int minn=inf,ans;
for(int i=;i<flag;i++)
{
int v=check(l[i]);
if(v<minn)
{
minn=v;
ans=l[i];
}
}
int ji=,lu=;
for(int i=;i<n;i++)
if(a[i]<=ans)
ji++;
for(int i=;i<m;i++)
if(b[i]>ans)
lu++;
printf("%d:%d",*n-ji,*m+lu);
return ;
}

Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分的更多相关文章

  1. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 暴力水题

    C. Vasya and Basketball time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 排序

    C. Vasya and Basketball   Vasya follows a basketball game and marks the distances from which each te ...

  3. Codeforces Round #281 (Div. 2) B. Vasya and Wrestling 水题

    B. Vasya and Wrestling 题目连接: http://codeforces.com/contest/493/problem/B Description Vasya has becom ...

  4. Codeforces Round #281 (Div. 2) D. Vasya and Chess 水

    D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #281 (Div. 2) D. Vasya and Chess 镜面对称 博弈论

    D. Vasya and Chess time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力水题

    A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. Codeforces Round #281 (Div. 2) D. Vasya and Chess 博弈

    D. Vasya and Chess   Vasya decided to learn to play chess. Classic chess doesn't seem interesting to ...

  8. Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

    A. Vasya and Football   Vasya has started watching football games. He has learned that for some foul ...

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

    简单题,却犯了两个错误导致WA了多次. 第一是程序容错性不好,没有考虑到输入数据中可能给实际已经罚下场的人再来牌,这种情况在system测试数据里是有的... 二是chronologically这个词 ...

随机推荐

  1. ubuntu安装最新版本的node.js

    下面的方法适用于最新版本的Ubuntu.Ubuntu 12.04 LTS.Ubuntu 12.10.Ubuntu 13.04等版本.它可以帮助开发者在Ubuntu上安装Node.js,无需从头编译安装 ...

  2. Nginx+Keepalived实现 转载

    一.Keepalived简介 keepalived是一个类似于layer3, 4 & 5交换机制的软件,也就是我们平时说的第3层.第4层和第5层交换.Keepalived的作用是检测web服务 ...

  3. JVM学习笔记(一)------基本结构【转】

    转自:http://blog.csdn.net/cutesource/article/details/5904501 版权声明:本文为博主原创文章,未经博主允许不得转载. 从Java平台的逻辑结构上来 ...

  4. JDBC的几种驱动

    不同的数据库的驱动是不同的 其中:Access驱动串---------sun.jdbc.odbc.JdbcOdbcDriver    MySQL驱动串---------com.mysql.jdbc.D ...

  5. Tutorial: WPF User Control for AX2012

    原作者: https://community.dynamics.com/ax/b/goshoom/archive/2011/10/06/tutorial-wpf-user-control-for-ax ...

  6. Hibernate API申明事务边界

    在Hibernate API中,Session和Transaction接口提供了以下声明事务边界的方法: 声明事务的开始边界: Transaction tx = session.beginTransa ...

  7. HDU 4315:Climbing the Hill(阶梯博弈)

    http://acm.hdu.edu.cn/showproblem.php?pid=4315 题意:有n个人要往坐标为0的地方移动,他们分别有一个位置a[i],其中最靠近0的第k个人是king,移动的 ...

  8. js格式化日期 年月日

    /**                     * 格式化日期                     * @param value                     * @param row  ...

  9. 周赛-The Number Off of FFF 分类: 比赛 2015-08-02 09:27 3人阅读 评论(0) 收藏

    The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...

  10. JAVA基础知识之JVM-——URLClassLoader

    URLClassLoader是ClassLoader的一个实现类,它既能从本地加载二进制文件类,也可以从远程加载类. 它有两个构造函数, 即 URLClassLoader(URL[] urls),使用 ...