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. C#之文件缓存

    写在开头 今天就放假了,照理说应该写今年的总结了,但是回头一看,很久没有写过技术类的文字了,还是先不吐槽了. 关于文件缓存 写了很多的代码,常常在写EXE(定时任务)或者写小站点(数据的使用和客户端调 ...

  2. 剑指offer试题(PHP篇二)

    6.旋转数组的最小数字 题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1 ...

  3. IQKeyboardManager 自动处理键盘事件的第三方库

    我们写界面要考虑很多用户体验问题,键盘事件的响应就是比较麻烦的一种.我们需要监听键盘事件,考虑点击背景收起键盘.考虑键盘遮挡输入框问题等等,而且每个界面都要做这么一套.这个库帮我们解决了这个事情. 这 ...

  4. centos 环境变量配置

    CentOS系统下如何将PHP和mysql命令加入到环境变量中,在Linux CentOS系统上 安装完php和MySQL后,为了使用方便,需要将php和mysql命令加到系统命令中,如果在没有添加到 ...

  5. 腾讯云微计算实践:从Serverless说起,谈谈边缘计算的未来

    欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 作者:黄文俊,腾讯云高级产品经理,曾经历过企业级存储.企业级容器平台等产品的架构与开发,对容器.微服务.无服务器.DevOps等都有浓厚兴趣. ...

  6. python 列表去重(数组)的几种方法(转)

    一.方法1  代码如下 复制代码 ids = [1,2,3,3,4,2,3,4,5,6,1] news_ids = [] for id in ids:     if id not in news_id ...

  7. MySQL安装与使用过程中的相关问题

    数据库远程连接拒绝访问解决办法: 1. 改表法.可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql&q ...

  8. js中的写出想jquery中的函数一样调用

    1.IIFE: Immediately-Invoked function Expression 函数模块自调用 2.代码实现 <!DOCTYPE html> <html lang=& ...

  9. .addClass(),.removeClass(),.toggleClass()的区别

    .addClass("className")方法是用来给指定元素增加类名,也就是说给指定的元素追加样式: 可以同时添加多个类名,空格符隔开 $("selector&quo ...

  10. hihoCoder 1523 数组重排2 贪心

    题意:给定一个1-N的排列A1, A2, - AN,每次操作小Hi可以选择一个数,把它放到数组的最左边. 请计算小Hi最少进行几次操作就能使得新数组是递增排列的. 思路:最后的序列是递增的,那么必定满 ...