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;
}

 

转载于:https://www.cnblogs.com/qscqesze/p/4143286.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值