zoukankan      html  css  js  c++  java
  • J

    This year at Monsters University it is decided to arrange Scare Games. At the Games all campus gathers at the stadium stands, and the Scare program students divide into two teams to compete in their abilities of scaring children. This year the two teams will be “Oozma Kappa” and “Roar Omega Roar”.
    Each team has n monsters, and the Games consist of n challenges. During each challenge Dean Hardscrabble, the chair of the Scare program, invites one monster from each team to demonstrate his mastery. Each of the monsters is invited only once and scores from 0 to 6 points, depending on how much a child is scared. The results of each challenge are announced at the same time for both monsters right after the end of this challenge. The winning team will be identified by the sum of the points scored by all its members.
    Sports competition is an unpredictable process. But the Dean wants to keep all the course of the Games under control, so that the identity of the winning team will have been unclear for the audience as long as possible. For example, if six challenges until the end “Oozma Kappa” is forty points ahead, the audience at the stadium stands will just lose interest to the game. The Dean knows the skill level of all her students, and she wants to decide beforehand the order in which both teams’ members will be participating in the challenges. In what order should monsters from “Oozma Kappa” and from “Roar Omega Roar” show up to keep the audience in suspense as long as possible?

    Input

    The first line contains an integer n (2 ≤ n ≤ 1 000). The second line contains n integers within the range from 0 to 6, which are the points monsters from “Oozma Kappa” will score. The third line contains the points, monsters from “Roar Omega Roar” will score, written in the same manner.

    Output

    Output n lines, each containing integers o i and r i, which are the numbers of monsters from “Oozma Kappa” and “Roar Omega Roar” respectively, who should be called by the Dean to take part in the i-th challenge. In each team monsters are numbered with integers from 1 to n in the order they appear in the input data. If the problem has several solutions, output any of them.

    Example

    inputoutput
    5
    0 1 4 3 6
    6 5 1 3 0
    
    5 1
    1 5
    4 4
    2 3
    3 2
    

    Hint

    /*
    * @Author: lyuc
    * @Date:   2017-04-30 16:02:54
    * @Last Modified by:   lyuc
    * @Last Modified time: 2017-04-30 16:37:02
    */
    /**
     * 题意:两个队伍比赛,每次每队派一名怪兽出来,已知每个怪兽能获得分数,最后分数高的队伍获胜
     *         为了比赛的悬念尽可能的留在最后,请你安排怪兽出场的顺序
     *
     * 思路:首先统计一下每个队伍的每个队伍的得分,肯定分数多的获胜,然后分数多的队伍从小到大输
     *         出,分数少的从大到小输出
     */
    #include <iostream>
    #include <stdio.h>
    #include <algorithm>
    using namespace std;
    struct node{
        int id,val;
    }a[1005],b[1005];
    int n;
    bool cmp1(node a,node b){
        return a.val<b.val;
    }
    bool cmp2(node a,node b){
        return a.val>b.val;
    }
    int res1,res2;
    void init(){
        res1=0;
        res2=0;
    }
    int main(){
        // freopen("in.txt","r",stdin);
        init();
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            a[i].id=i+1;
            scanf("%d",&a[i].val);
            res1+=a[i].val;
        }
        for(int i=0;i<n;i++){
            b[i].id=i+1;
            scanf("%d",&b[i].val);
            res2+=b[i].val;
        }
        if(res1>res2){
            sort(a,a+n,cmp1);
            sort(b,b+n,cmp2);
            for(int i=0;i<n;i++){
                printf("%d %d
    ",a[i].id,b[i].id);
            }
        }else{
            sort(a,a+n,cmp2);
            sort(b,b+n,cmp1);
            for(int i=0;i<n;i++){
                printf("%d %d
    ",a[i].id,b[i].id);
            }
        }
        return 0;
    }
  • 相关阅读:
    两个泛型实例之间的属性变化
    C#
    字符编码
    如何在阿里云 CentOS 8 / RHEL 8 上安装 vsftpd(ftp 服务器)
    使用 ASP.NET Core 创建 Web API使用 JavaScript 调用报错 webapi Unable to get items. TypeError: Failed to fetch
    让WPF程序启动时以管理员身份运行(转载)
    WPF任务栏同步进度
    C# ref and out
    C# 中 string.Empty、""、null的差别
    如何读写拥有命名空间xmlns 属性的Xml文件(C#实现)
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/6789756.html
Copyright © 2011-2022 走看看