Vasya and Basketball

来源:互联网 发布:spss卡方检验数据输入 编辑:程序博客网 时间:2024/06/06 19:03
#include <iostream>
#include <algorithm>
#include <stdio.h>


using namespace std;
int num1[211111];
int num2[211111];
int num[411111];
long long res1, res2;
long long ans1, ans2;
int n, m;


int main()
{


    while(scanf("%d",&n) != EOF && n)
    {
        int r = 0;
        for(int i = 0; i < n; i++)
         scanf("%d",&num1[i]), num[i] = num1[i];
        scanf("%d",&m);
        for(int j = 0; j < m; j++)
         scanf("%d",&num2[j]), num[j+n] = num2[j];
        int tot1 = n*3,tot2 = m*3;
        int ans = tot1 - tot2;


        int l1 = 0, l2 = 0;
        sort(num1, num1 + n);
        sort(num2, num2 + m);
        sort(num, num + n + m);
        int ans1 = tot1, ans2 = tot2;
        for( int i = 0; i < n+m; i++)
        {


             while(l1 < n && num1[l1] <= num[i]) l1++;
             while(l2 < m && num2[l2] <= num[i]) l2++;
             tot1  = (n-l1)*3 + l1*2;
             tot2  = (m-l2)*3 + l2*2;
             if(tot1 - tot2 > ans)
             {
                 ans = tot1 - tot2;
                 ans1 = tot1;
                 ans2 = tot2;
             }
        }
       printf("%d:%d\n",ans1, ans2);
    }
}
0 0
原创粉丝点击