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. Java—将文件压缩为zip文件

    import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import ...

  2. fcc html5 css 练习3

    行内样式看起来是这样的 <h1 style="color: green"> .pink-text { color: pink !important; }         ...

  3. [Android]异常5-throwable:java.lang.OutOfMemoryError: pthread_create

    背景:线程初始化耗时任务 异常原因: 可能一>多个new Thread()嵌套 解决办法有: 解决一>使用Handler分离new Thread()嵌套 注: 06-30 09:12:26 ...

  4. Java 中访问数据库的步骤?Statement 和PreparedStatement 之间的区别?

    Java 中访问数据库的步骤?Statement 和PreparedStatement 之间的区别? Java 中访问数据库的步骤 1)注册驱动: 2)建立连接: 3)创建Statement: 4)执 ...

  5. 【技术累积】【点】【java】【30】代理模式

    基础 代理模式是Java常见的设计模式之一.所谓代理模式是指客户端并不直接调用实际的对象,而是通过调用代理,来间接的调用实际的对象. 什么是代理 参考现实生活中的代理 比如某个品牌的某个省的代理商,作 ...

  6. Java多线程学习笔记(三)——Future和FutureTask

    Future接口:它是对于具体的Runnable或者Callable任务的执行结果进行取消.查询是否完成.获取结果.必要时可以通过get方法获取执行结果,该方法会阻塞直到任务返回结果. 接口中有5中方 ...

  7. .net 内嵌 GeckoWebBrowser (firefox) 核心浏览器

    引用nuget包: 注意:Geckofx45 nuget包必须是最后引用,否则初始化会出错 简单示例: using Gecko; using System; using System.Collecti ...

  8. centos7安装个人网盘nextcloud

    本节介绍如何在centos7上建立个人云盘nextcloud服务器 第一:建立用户nextcloud 第二:安装下载工具wget 第三:把nextcloud账号添加到sudoers目录下 第四:切换到 ...

  9. BZOJ 2850: 巧克力王国 KDtree + 估价函数

    Code: #include<bits/stdc++.h> #define maxn 100000 #define inf 1000000008 #define mid ((l+r)> ...

  10. Luogu P3901 数列找不同

    由于技术原因,题目我贴不上了,大家点下面的链接自己去看吧^_^ P3901 数列找不同 这题第一眼看去,题面真短,有坑(flag) 在往下面看去,woc数据这么大,你要怎样. 现在一起想想想,超级侦探 ...