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.

Example

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

两支队伍a,b,a进了n球 下面n个数为a队进球距离球筐的距离,
b进了m球,下面m个数为b队进球距离球筐的距离,
问三分线为多少时a队与b队的比分差值最大
输出比分 答案优先输出a大的。 temp1=upper_bound(a,a+n,a[i])-a;
temp1=temp1*2+(n-temp1)*3;
upper_bound返回的是第一个大于a[i]的元素的指针,
数组从0开始,所以temp对应的就是小于a[i]的元素的个数
 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int a[],b[];
int main() {
int n,m,x,y;
while(scanf("%d",&n)!=EOF){
for (int i= ;i<n ;i++) scanf("%d",&a[i]);
scanf("%d",&m);
for (int i= ;i<m ;i++) scanf("%d",&b[i]);
if (n>=m) {
x=*n;
y=*m;
}else {
x=*n;
y=*m;
}
int temp1,temp2;
sort(a,a+n);
sort(b,b+m);
for (int i= ;i<n ;i++ ){
temp1=upper_bound(a,a+n,a[i])-a;
temp2=upper_bound(b,b+m,a[i])-b;
temp1=temp1*+(n-temp1)*;
temp2=temp2*+(m-temp2)*;
if (temp1-temp2==x-y){
if (temp1>x){
x=temp1;
y=temp2;
}
}else if (temp1-temp2>x-y){
x=temp1;
y=temp2;
}
}
for (int i= ;i<m ;i++ ){
temp1=upper_bound(a,a+n,b[i])-a;
temp2=upper_bound(b,b+m,b[i])-b;
temp1=temp1*+(n-temp1)*;
temp2=temp2*+(m-temp2)*;
if (temp1-temp2==x-y){
if (temp1>x){
x=temp1;
y=temp2;
}
}else if (temp1-temp2>x-y){
x=temp1;
y=temp2;
}
}
printf("%d:%d\n",x,y);
}
return ;
}

Vasya and Basketball CodeForces - 493C的更多相关文章

  1. Codeforces 493C - Vasya and Basketball

    C. Vasya and Basketball 题目链接:http://codeforces.com/problemset/problem/493/C time limit per test 2 se ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. cf493C Vasya and Basketball

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

  6. 【Codeforces 493C】Vasya and Basketball

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h& ...

  7. codeforces 493 C Vasya and Basketball

    题意:给出三分线的值d,分别有两支队伍,如果小于等于d,得2分,如果大于d,得三分,问使得a-b最大时的a,b 一看到题目,就想当然的去二分了----啥都没分出来---55555555 后来才知道不能 ...

  8. Vasya and Multisets CodeForces - 1051C(英语限制了我的想象力)

    题意: 对输入的每个数都进行分配到两个多重集中,问分配完以后 每个多重集中的个数为1的元素是否相等  相等则输出一个分配方式, 不想等为NO 解析: 三种情况 1.原数列中个数为1 的数的个数为偶数 ...

  9. Vasya and Shifts CodeForces - 832E (高斯消元)

    大意: 给定$4n$个$m$位的五进制数, $q$个询问, 每个询问给出一个$m$位的五进制数$b$, 求有多少种选数方案可以使五进制异或和为$b$. 高斯消元入门题 每次询问相当于就是给定了$m$个 ...

随机推荐

  1. 最大流模版 dinic

    朴素dinic+多路增广 #include <iostream> #include <cstdio> #include <cstring> #include < ...

  2. bzoj 4591: [Shoi2015]超能粒子炮·改 [lucas定理]

    4591: [Shoi2015]超能粒子炮·改 题意:多组询问,求 \[ S(n, k) = \sum_{i=0}^n \binom{n}{i} \mod 2333,\ k \le n \le 10^ ...

  3. qt的信号与槽函数

    关联: bool connect ( const?QObject?*?sender, const?char?*?signal, const QObject * receiver, const char ...

  4. 爬虫(Spider),反爬虫(Anti-Spider),反反爬虫(Anti-Anti-Spider)

    爬虫(Spider),反爬虫(Anti-Spider),反反爬虫(Anti-Anti-Spider),这之间的斗争恢宏壮阔... Day 1小莫想要某站上所有的电影,写了标准的爬虫(基于HttpCli ...

  5. 洛谷 P2073 送花【Treap】题解+AC代码

    题目背景 小明准备给小红送一束花,以表达他对小红的爱意.他在花店看中了一些花,准备用它们包成花束. 题目描述 这些花都很漂亮,每朵花有一个美丽值W,价格为C. 小明一开始有一个空的花束,他不断地向里面 ...

  6. 通过实例介绍持续集成的应用--基于Jenkins

    1.测试工程师为什么要掌握持续集成 一个程序员如果想发布一个产品,他需要编码.编译.测试,发布的过程.对于一个企业来说,如果也想发布一个产品的话,同样的也是需要上述的过程,区别在于企业要发布的产品的需 ...

  7. Servlet中文乱码问题解决办法

    首先对于源jsp网站和servlet里面的字符集要一样,一般支持中文的字符集为UTF-8最好采用这个字符集(除此之外还有gb2312); 对于源jsp文件的代码中需要设置 设置你的page里面的字符集 ...

  8. PHP文件头BOM头问题

    前几天我们公司服务器出现了一个离奇的问题,服务器与本地文件代码完全一致,本地运行正常,到了测试环境服务器之后,各种问题一个又一个浮现,先是后台验证码不显示,以为是session写入失败,又是怀疑gd库 ...

  9. SQLite常用函数及语句

    SQLite3.0使用的是C的函数接口,常用函数如下: sqlite3_open() //打开数据库 sqlite3_close() //关闭数据库 sqlite3_exec() //执行sql语句, ...

  10. java基础--面对对象

    面对对象--概述 什么是对象? +---->对象可以泛指一切现实中存着的事物 +---->类是对象的抽象集合 什么是面对对象? +--->万物皆对象,面对对象实际就是人与万物接触== ...