码迷,mamicode.com
首页 > 其他好文 > 详细

J - Scarily interesting! URAL - 2021

时间:2017-04-30 17:11:26      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:分数   identity   number   result   example   har   比赛   each   line   

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\n",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\n",a[i].id,b[i].id);
        }
    }
    return 0;
}

 

J - Scarily interesting! URAL - 2021

标签:分数   identity   number   result   example   har   比赛   each   line   

原文地址:http://www.cnblogs.com/wuwangchuxin0924/p/6789756.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!