C. Vasya and Basketball
 

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

Sample test(s)
input
3
1 2 3
2
5 6
output
9:6
题意:投篮比赛,给你两个人投进篮球的距离,让你找到一个d使得小于等于d的距离的投篮得分为2,大于d的距离得分为3,同时使得a-b得分差最大
        如果有a-b相同的情况,尽量使a最大
题解:按照分差排序同时a尽量大,就行了
///meek
#include<bits/stdc++.h>
using namespace std; typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//****************************************
const int N=;
#define mod 10000007
#define inf 2000000007
#define maxn 10000 ll lna,lnm,n,a[N],b[N],m; struct ss{
ll x,in,index;
}s[N+N];
struct sss {
ll x,aa;
int in;
}W[N+N];
int cmp(ss s1,ss s2) {
if(s1.x==s2.x) return s1.in<s2.in;
return s1.x<s2.x;
}
int cmp2(sss s1,sss s2) {
if(s1.x==s2.x) return s1.aa<s2.aa;
else return s1.x<s2.x;
}
int main() { n=read();
int k=;
for(int i=;i<=n;i++) {
scanf("%I64d",&a[i]);
s[++k].x=a[i];
s[k].in=;
s[k].index=i;
}
m=read();
for(int i=;i<=m;i++) {
scanf("%I64d",&b[i]);
s[++k].x=b[i];
s[k].in=;
s[k].index=i;
}
sort(s+,s+k+,cmp);
ll l=,r=;
for(int i=;i<=k;i++) {
if(s[i].in==) {
l++;
}
else r++;
W[i].x=(l*+(n-l)*)-(r*+(m-r)*);
W[i].aa=(l*+(n-l)*);
W[i].in=i;
}
W[++k].x=n*-m*;
W[k].aa=(n*);
W[k].in=-;
W[++k].x=n*-m*;
W[k].aa=(n*);
W[k].in=-;
sort(W+,W+k+,cmp2);
ll ansl=,ansr=;
ansl=W[k].aa;ansr=W[k].aa-W[k].x;
cout<<ansl<<":"<<ansr<<endl;
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 time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  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. Struts2之一 初体验

    Struts2 框架是基于MV模式开发的,它提供了一个核心控制器,用于对所有的请求进行统一处理,这个控制器是由一个名为FilterDispatcher的Servlet过滤器来充当的. 01.需要在we ...

  2. 获取Google地图位置坐标并嵌入到网页

    有时候做网页的时候,可能需要一个地图显示,可能会用到Google地图,所以就分享一下get到的新技能.在网上查资料的时候有这种方式 但是我没做成功,所以找了其他的方式. 首先,打开Google地图,查 ...

  3. JS——动态添加事件和移除事件(有待补充...)

    动态的添加事件:利用 attachEvent 和 addEventListener IE 支持 attachEvent: obj.attachEvent("onclick", Fo ...

  4. Java_Web三大框架之Hibernate+HQL语言基础

    12.1 HQL语言基础Hibernate查询语言为HQL(Hibernate Query Language),可以直接使用实体类名及属性.HQL语法类似于SQL,有SQL的关键词如select.fr ...

  5. nc的简单使用

    1.传输文件: 目的主机监听 nc -l 监听端口<未使用端口>  > 要接收的文件名 nc -l 6666 > filename.tar 源主机发起请求 nc  目的主机ip ...

  6. hdu,1028,整数拆分的理解

    #include"iostream"using namespace std;int main() { int n,i,j,k; int c[122],temp[122]; //c[ ...

  7. C/C++ 之数组排序

    #include <stdio.h> #include <stdlib.h> void array_sort(int *a, int len) { int i, j, tmp; ...

  8. 如何让git忽略指定的文件

    有些文件,我们修改后,并不需要git提交更改,可以在.gitignore里面设置过滤规则 在.gitignore文件里面输入 *.zip 表示所有zip文件忽略更改 /bin 表示忽略整个根目录的bi ...

  9. 7-11 社交网络图中结点的“重要性”计算 (30 分)(Dijkstra算法)

    题意:  思路:对每个输入的点跑一遍dijkstra算法,然后对这个点到所有点的距离求和按公式输出就可以了. (这次尝试了用数组模拟链表来做最短路问题,刷新了自己对最短路的理解) 这里构造链表的过程我 ...

  10. 【codeforces 757D】Felicity's Big Secret Revealed

    [题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...