zoukankan      html  css  js  c++  java
  • Scarily interesting! (URAL

    Problem

    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 nintegers 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

    input output
    5
    0 1 4 3 6
    6 5 1 3 0
    
    5 1
    1 5
    4 4
    2 3
    3 2

    题解:题意就是在已经知道那个队会赢得前提下,又知道了每个队员会得的分数,怎么让他们之前的对战变得更有悬念。我理解的就是由败转变胜利就是一种悬念的方式。所以排下序,让输的那一队先派出得分多的,让赢得那一队先派出得分少的,尽可能让悬念大一些。

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <queue>
    #include <cmath>
    using namespace std;
    struct node
    {
        int fen;
        int num;
    } a[1010], b[1010];
    bool cmp1(struct node x, struct node y)
    {
        return x.fen < y.fen;
    }
    bool cmp2(struct node x, struct node y)
    {
        return x.fen > y.fen;
    }
    int main()
    {
        int n,sum1,sum2;
        scanf("%d", &n);
        sum1 = sum2= 0;
        for(int i =1; i <= n; i ++)
        {
            scanf("%d",&a[i].fen);
            a[i].num = i;
            sum1 += a[i].fen;
        }
        for(int i =1; i <= n; i ++)
        {
            scanf("%d",&b[i].fen);
            b[i].num = i;
            sum2+=b[i].fen;
        }
        int f = 0;
        if(sum1 >= sum2)f =1;
        if(f==1)
        {
            sort(a + 1, a + 1 + n, cmp1);
            sort(b + 1, b + 1 + n, cmp2);
            for(int i = 1; i <= n; i ++)printf("%d %d
    ",a[i].num,b[i].num);
        }
        else
        {
            sort(a + 1, a + 1 + n, cmp2);
            sort(b + 1, b + 1 + n, cmp1);
            for(int i = 1; i <= n; i ++)printf("%d %d
    ",a[i].num,b[i].num);
        }
        return 0;
    }
  • 相关阅读:
    误加all_load引起的程序报错
    ConstraintLayout 约束布局
    前端判断是否APP客户端打开触屏,实现跳转APP原生组件交互之遐想
    TP5 多条件whereOr查询
    json手动解析详解
    Centos python 2.6 升级到 2.7
    js中click重复执行
    使用 Python 实现实用小工具
    使用 Python 编写密码爆破工具
    使用Python进行无线网络攻击
  • 原文地址:https://www.cnblogs.com/lcchy/p/10139623.html
Copyright © 2011-2022 走看看