URAL - 2021 Scarily interesting!(贪心)

点击打开题目链接

2021. Scarily interesting!

Time limit: 1.0 second
Memory limit: 64 MB
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.

Sample

inputoutput
5
0 1 4 3 6
6 5 1 3 0
5 1
1 5
4 4
2 3
3 2
Problem Author: Oleg Dolgorukov
Problem Source: NEERC 2014, Eastern subregional contest
Tags: none   (

hide tags for unsolved problems

)

拿到题目开始yy,老板想让比赛更有悬念,所以每场比赛都要悬而未决,所以让得分差不多的比,看了一下样例,(这题坑就在样例上了 TAT)更加确信的交了一发WA。

后仔细读题发现题意是:结果已经确定,要使得观众猜不出最后谁会赢。

思路:每次让赢队的最少分数和输队的最大分数比,才不易猜出

以后做题还是少yy吧。QAQ

附上AC代码:

#include<iostream>
#include<algorithm>

using namespace std;
const int maxn=2000+5;
int n;
int sum1,sum2;

struct edges{
int score,id;
}edge1[maxn],edge2[maxn];

bool cmp1(const edges a,const edges b)
{
    return a.score<b.score;
}

bool cmp2(const edges a,const edges b)
{
    return a.score>b.score;
}

int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        sum1=sum2=0;
        for(int i=0;i<n;i++)
        {
            cin>>edge1[i].score;
            sum1+=edge1[i].score;
            edge1[i].id=i+1;
        }
        for(int i=0;i<n;i++)
        {
            cin>>edge2[i].score;
            sum2+=edge2[i].score;
            edge2[i].id=i+1;
        }
        if(sum1>sum2)
        {
            sort(edge1,edge1+n,cmp1);
            sort(edge2,edge2+n,cmp2);
            for(int i=0;i<n;i++)
                cout<<edge1[i].id<<' '<<edge2[i].id<<endl;
        }
        else
        {
            sort(edge1,edge1+n,cmp2);
            sort(edge2,edge2+n,cmp1);
            for(int i=0;i<n;i++)
                cout<<edge1[i].id<<' '<<edge2[i].id<<endl;
        }
    }
    return 0;
}

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chook_lxk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值