zoukankan      html  css  js  c++  java
  • 田忌赛马---空手道俱乐部

    #include <cstdio>
    #include <cstring>
    #include<iostream>
    #include<queue>
    #include<stack>
    #include<cmath>
    #include <map>
    #include <algorithm>
    using namespace std;
    map<string, string>mp;
    vector<vector<int> >G;
    
    const int INF=0x3f3f3f3f;
    const int maxn=1100;
    int a[maxn], b[maxn];
    int n, m;
    
    
    int main()
    {
        int T, cas=1;
        scanf("%d", &T);
    
        while(T--)
        {
            scanf("%d", &n);
    
            for(int i=1; i<=n; i++)
                scanf("%d", &a[i]);
            for(int i=1; i<=n; i++)
                scanf("%d", &b[i]);
            sort(a+1, a+n+1);
            sort(b+1, b+n+1);
    
            int la, lb, ra, rb, ans;
            ans=0;
            la=lb=1;
            ra=rb=n;
    
            for(int i=1; i<=n; i++)
            {
                if(a[ra] > b[rb])
                {
                    ans+=2;
                    ra--;
                    rb--;
                }
    
                else if(a[ra] < b[rb])
                {
                    la++;
                    rb--;
                }
    
                else if(a[la] > b[lb])
                {
                    ans+=2;
                    la++;
                    lb++;
                }
    
                else
                {
                    if(a[la]==b[rb])
                        ans++;
                    la++;
                    rb--;
                }
            }
            printf("Case %d: %d
    ", cas++, ans);
        }
        return 0;
    }
    View Code


    Light OJ---1198

    Description

    Your karate club challenged another karate club in your town. Each club enters N players into the match, and each player plays one game against a player from the other team. Each game that is won is worth 2 points, and each game that is drawn is worth 1 point. Your goal is to score as many points as possible.

    Your secret agents have determined the skill of every member of the opposing team, and of course you know the skill of every member of your own team. You can use this information to decide which opposing player will play against each of your players in order to maximize your score. Assume that the player with the higher skill in a game will always win, and if the players have the same skill then they will draw.

    You will be given the skills of your players and of the opposing players, you have to find the maximum number of points that your team can score.

    Input

    Input starts with an integer T (≤ 70), denoting the number of test cases.

    Each case starts with a line containing an integer N (1 ≤ N ≤ 50). The next line contains N space separated integers denoting the skills of the players of your team. The next line also contains N space separated integers denoting the skills of the players of the opposite team. Each of the skills lies in the range [1, 1000].

    Output

    For each case, print the case number and the maximum number of points your team can score.

    Sample Input

    4

    2

    4 7

    6 2

    2

    6 2

    4 7

    3

    5 10 1

    5 10 1

    4

    10 7 1 4

    15 3 8 7

    Sample Output

    Case 1: 4

    Case 2: 2

    Case 3: 4

    Case 4: 5

  • 相关阅读:
    反射 Reflection
    后台输出的数据进行字符判断,小数点后边是0不显示,不是0显示
    判断input内的字符是不是数字或字母
    手机端底部按钮隐藏与显示
    CSS改变checkbox样式
    js小数取整 小数保留两位
    如何判断打开页面时使用的设备?
    H5 拖放实例
    根据手机系统引入不同的css文件
    HTML 5 video 视频标签全属性详解(转)
  • 原文地址:https://www.cnblogs.com/w-y-1/p/5724970.html
Copyright © 2011-2022 走看看