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
standard input
output
standard output

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 - 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
Input
5
6 7 8 9 10
5
1 2 3 4 5
Output
15:10

NOTE
#include <cstdio>

#include <cmath>

#include <cstring>

#include <ctime>

#include <iostream>

#include <algorithm>

#include <set>

#include <vector>

#include <sstream>

#include <queue>

#include <typeinfo>

#include <fstream>

typedef long long ll;

using namespace std;

//freopen("D.in","r",stdin);

//freopen("D.out","w",stdout);

#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)

struct point{

    int a;

    int b;

};

point num[1000000];

bool cmp(point a,point b)

{

    if(a.a==b.a)

        return a.b>b.b;

    return a.a>b.a;

}

bool cmp1(point a,point b)

{

    if(a.a==b.a)

        return a.b<b.b;

    return a.a>b.a;

}

int main()

{

    int n1;

    cin>>n1;

    for(int i=0;i<n1;i++)

    {

        cin>>num[i].a;

        num[i].b=1;

    }

    int n2;

    cin>>n2;

    for(int i=0;i<n2;i++)

    {

        cin>>num[n1+i].a;

        num[n1+i].b=2;

    }

    sort(num,num+n1+n2,cmp);

    int ans=0;

    int kill=0;

    int flag=0;

    int flag2=0;

    for(int i=0;i<n1+n2;i++)

    {

        if(num[i].b==2)

            ans--;

        if(num[i].b==1)

            ans++;

        if(ans>0)

            ans=0;

        if(ans==0)

            flag=i;

    }

    int ans1=0;

    int ans2=0;

    for(int i=0;i<n1+n2;i++)

    {

        if(i<=flag)

        {

            if(num[i].b==1)

                ans1+=3;

            if(num[i].b==2)

                ans2+=3;

        }

        if(i>flag)

        {

            if(num[i].b==1)

                ans1+=2;

            if(num[i].b==2)

                ans2+=2;

        }

    }

    if(num[flag].b==2)

    {

        ans2-=1;

    }

    cout<<ans1<<":"<<ans2<<endl;

    return 0;

}

 

你可能感兴趣的:(codeforces)