题目链接:这里
题意:两个人比赛篮球投篮,与正常的篮球比赛不同的是,三分线与篮筐的距离d是不确定的。输入第一个人投了n个球,n个球每个球投的时候他与篮筐的距离;然后输入第二个人头了m个球,m个球每个球投的时候他与篮筐的距离,然后让你选择一个d,使得它对于第一个人最为有利,所谓有利即使得“第一个人的分数-第二个人的分数”最大,将比分输出。当有多个相同的最大差值的情况时,输出第一个人分数最大的那组。这个英语表述真几把坑,读了一年。
解法:只要对于枚举的一个距离x,每个人得到的分数则可以表示成:(比x近的个数)*2 + (比x远的个数)*3 所以只需要枚举(m+n+1)种情况,然后分别二分找到枚举的距离在n个球和m个球中的排第几,即可算出两者分差。

//CF 493C

#include <bits/stdc++.h>
using namespace std;

const int maxn = 200010;
long long a[maxn], b[maxn], c[maxn*2];
int n, m, cnt;

int main()
{
    scanf("%d", &n);
    cnt = 1;
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]), c[cnt++] = a[i];
    scanf("%d", &m);
    for(int i = 1; i <= m; i++) scanf("%lld", &b[i]), c[cnt++] = b[i];
    sort(a + 1, a + n + 1);
    sort(b + 1, b + m + 1);
    sort(c + 1, c + cnt);
    long long ans = -1e10;
    long long x, y;
    if(ans < 2LL*(n-m)){
        ans = 2LL*(n-m);
        x = 2LL*n;
        y = 2LL*m;
    }
    for(int i = 0; i < cnt; i++){
        int pos1 = upper_bound(a + 1, a + n + 1, c[i]) - a - 1;
        int pos2 = upper_bound(b + 1, b + m + 1, c[i]) - b - 1;
        long long sum = (long long)pos1*2LL + (long long)(n-pos1)*3LL -
        (long long)pos2*2LL - (long long)(m-pos2)*3LL;
        if(ans < sum){
            ans = sum;
            x = (long long)pos1*2LL + (long long)(n-pos1)*3LL;
            y = (long long)pos2*2LL + (long long)(m-pos2)*3LL;
        }
        else if(ans == sum){
            if(x < (long long)pos1*2LL + (long long)(n-pos1)*3LL){
                x = (long long)pos1*2LL + (long long)(n-pos1)*3LL;
                y = (long long)pos2*2LL + (long long)(m-pos2)*3LL;
            }
        }
    }
    printf("%lld:%lld\n", x, y);
    return 0;
}