Codeforce 493c

H - 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
 
typedef long long LL;
const int N = 200005;
LL n, m, a[N], b[N], mi, mj, ans;
int main()
{
 
    scanf("%I64d", &n);
    for(int i = 0; i < n; ++i) scanf("%I64d", &a[i]);
 
    scanf("%I64d", &m);
    for(int i = 0; i < m; ++i) scanf("%I64d", &b[i]);
 
    sort(a, a + n);
    sort(b, b + m);
    mi = n * 3;
    mj = m * 3;
    ans = mi - mj;
 
    for(int i = 0; i < n; ++i)
    {
        if(a[i] == a[i + 1] && i != n - 1) continue;//注意例子 5 2 2 2 2 2  3 2 2 2, 说明在枚举一串的时候, 相同值的应该用上界来尝试
        LL d = a[i];
        LL pos = upper_bound(b, b + m, d) - b;//注意uuper_bound 求上界的时候, 如果找到了, 还是返回 最后那个位置 + 1, 而如果要找的数大于数组里面的max, 返回的是 最大下标
        LL aa = (i + 1) * 2 + (n - i - 1) * 3;
        LL bb;
        if(d >= b[m - 1]) bb = 2 * m;
        else
            bb = (pos) * 2 + (m - pos) * 3;
        if(aa - bb > ans || (aa - bb == ans && aa > mi)) {
            ans = aa - bb;
            mi = aa;
            mj = bb;
        }
    }
 
 
    for(int i = 0; i < m; ++i)
    {
        if(b[i] == b[i + 1] && i != m - 1) continue;
        LL d = b[i];
        LL pos2 = upper_bound(a, a + n, d) - a;
        LL bb = (i + 1) * 2 + (m - i - 1) * 3;
        LL aa;
        if(d >= a[n - 1]) aa = 2 * n;
        else
            aa = (pos2) * 2 + (n - pos2) * 3;
        if(aa - bb > ans || (aa - bb == ans && aa > mi)) {
            ans = aa - bb;
            mi = aa;
            mj = bb;
         //  printf("[%d %d %d]\n", ans, mi, mj);
        }
    }
    printf("%I64d:%I64d\n", mi, mj);
}

  

posted @   JL_Zhou  阅读(205)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示