CodeForces 493C Vasya and Basketball(模拟 + 二分)

C - Vasya and Basketball
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

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.

Sample Input

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
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;


#define pb push_back
#define mp make_pair
#define fillchar(a, x) memset(a, x, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(a))
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r


typedef long long LL;
typedef pair<int, int > PII;
typedef unsigned long long uLL;

template<typename T>
void print(T* p, T* q, string Gap = " ") {
	int d = p < q ? 1 : -1;
	while(p != q) {
		cout << *p;
		p += d;
		if(p != q) cout << Gap;
	}
	cout << endl;
}
template<typename T>
void print(const T &a, string bes = "") {
	int len = bes.length();
	if(len >= 2)cout << bes[0] << a << bes[1] << endl;
	else cout << a << endl;
}

const LL INF = 1e17;
const int MAXM = 1e2 + 5;
const int MAXN = 2e5 + 5;
int n, m;
LL A[MAXN], B[MAXN];
LL z1, za1, zb1;

void cal(int k) {
	LL fa = lower_bound(A, A + n, k) - A, ba = n - fa;
	LL za = fa * 2 + ba * 3;
	LL fb = lower_bound(B, B + m, k) - B,bb = m - fb;
	LL zb = bb * 3 + fb * 2;
	if(za - zb > z1) {
		za1 = za;
		zb1 = zb;
		z1 = za1 - zb1;
	} else if(za - zb == z1 && za > za1) {
		za1 = za;
		zb1 = zb;
	}
}

int main() {
	while(~scanf("%d", &n)) {
		for(int i = 0; i < n; i ++) {
			scanf("%lld", &A[i]);
		}
		scanf("%d", &m);
		for(int i = 0; i < m; i ++) {
			scanf("%lld", &B[i]);
		}
		sort(A, A + n);
		sort(B, B + m);
		z1 = -INF, za1 = 0, zb1 = 0;
		for(int i = 0; i < n; i ++) {
			cal(A[i] - 1);
			cal(A[i]);
			cal(A[i] + 1);
		}
		for(int i = 0; i < m; i ++) {
			cal(B[i] - 1);
			cal(B[i]);
			cal(B[i] + 1);
		}
		printf("%lld:%lld\n", za1, zb1);
	}
	return 0;
}



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值