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. Android文件操作报open failed: EBUSY (Device or resource busy)

    Android删除文件后重新创建时偶尔出现 open failed: EBUSY (Device or resource busy)错误,该错误是Android系统的一个bug,大概的意思类似于win ...

  2. Hive扩展功能(四)--HiveServer2服务

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  3. mysql_数据查询_嵌套查询

    嵌套查询 一个SELECT-FROM-WHERE语句称为一个查询块. 嵌套查询:将一个查询块嵌套在另一个查询块的WHERE子句或者HAVING短语的条件中的查询. 注:子查询的SELECT语句中不能使 ...

  4. 为什么有些异常throw出去需要在函数头用throws声明,一些就不用

    throw new IllegalStateException(".");不用在函数头声明throws IllegalStateExceptionthrow new IOExcep ...

  5. Redis 之hash集合结构及命令详解

    1.hset key field value   作用: 把key中 filed域的值设为value 注:如果没有field域,直接添加,如果有,则覆盖原field域的值 2.hmset key fi ...

  6. Java中IO对象的输入输出流

    输入流: public void inputDemo () throws IOException { //文件名称 String fileName = "d:\\aaa.txt"; ...

  7. 10.3 io流 正篇 FileReader FileWriter读写代码

    一.FileWriter 小节: 1)FileWriter fw = new FileWriter("a.txt",true);//表示追加写入,默认是false.正常情况:执行多 ...

  8. shell使用eval进行赋值bc计算,bad substitution

    开始我认为是这样的: [root@jiangyi02.sqa.zmf /home/ahao.mah/ALIOS_TEST] #cat bbb.sh #!/bin/sh eval $1_new=123 ...

  9. vue-cli3 中的环境变量

    官方文档是这样写的: src同名文件夹下的建立 .env.[model] 配置文件  // mode:production development ... 载入的变量会对vue-cli-service ...

  10. chrome本地测试cookie时无效的原因

    https://blog.csdn.net/lyj787505955/article/details/38079079 应该是chrome的原因, 同一网页放在tomcat后,通过localhost方 ...