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. bzoj 1598: [Usaco2008 Mar]牛跑步 [k短路 A*] [学习笔记]

    1598: [Usaco2008 Mar]牛跑步 题意:k短路 ~~貌似A*的题目除了x数码就是k短路~~ \[ f(x) = g(x) + h(x) \] \(g(x)\)为到达当前状态实际代价,\ ...

  2. BZOJ 1969: [Ahoi2005]LANE 航线规划 [树链剖分 时间倒流]

    题意: 一张图,删除边,求两点之间的割边数量.保证任意时刻图连通 任求一棵生成树,只有树边可能是割边 时间倒流,加入一条边,就是两点路径上的边都不可能是割边,区间覆盖... 然后本题需要把边哈希一下, ...

  3. JS中的内置对象简介与简单的属性方法

    JS中的数组: 1.数组的概念: 数组是在内存中连续存储的多个有序元素的结构,元素的顺序称为下标,通过下标查找对应元素 2.数组的声明: ①通过字面量声明var arr1 = [,,,,] JS中同一 ...

  4. 小甲鱼OD学习第2讲

    这次我们的任务是让我们输入任意用户名密码判断正确 我们输入fishc和111111,显示错误 我们猜测这是用GetDlgItemTextW来收集账号密码的输入值 我们找到了两个函数,给这两个函数都下断 ...

  5. ES6标准入门 第一章:简介

    ECMAScript 6 是JavaScript 语言的下一代标准:发布于2015年,又称为ECMAScript 2015. ECMAScript 与 JavaScript 的关系:前者是后者的规范, ...

  6. virtualbox命令行共享CentOS目录

    virtualbox命令行共享CentOS目录   1. 安装virtualbox增强工具 "右ctrl+c" 显示和隐藏virtualbox虚拟机的菜单栏. 在VirtualBo ...

  7. Redis 实践1- redis介绍和安装

    redis是一个key-value存储系统,官方站点 http://redis.io   和memcached类似,但支持数据持久化 支持更多value类型,除了和string外,还支持hash.li ...

  8. Fiddler使用简单介绍

     一,fiddler简介 1.1,什么是fiddler Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的"进出&qu ...

  9. ng组件通讯的几种方式

    通过输入型绑定把数据从父组件传到子组件. 如<app-hero-child *ngFor="let hero of heroes"  [hero]="hero&qu ...

  10. jQuery(function(){...})与(function($){...})(jQuery)的“兄弟”情结

    记得那时在学习写基于jQuery的插件时,了解到(function($){...})(jQuery)的代码结构,一开始还没发觉,后来百度了解它的语意时,从搜索结果中发现了jQuery(function ...