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

Scarily interesting! (URAL - 2021)的更多相关文章

  1. A Unified Deep Model of Learning from both Data and Queries for Cardinality Estimation 论文解读(SIGMOD 2021)

    A Unified Deep Model of Learning from both Data and Queries for Cardinality Estimation 论文解读(SIGMOD 2 ...

  2. Tsunami: A Learned Multi-dimensional Index for Correlated Data and Skewed Workloads 论文解读(VLDB 2021)

    Tsunami: A Learned Multi-dimensional Index for Correlated Data and Skewed Workloads 论文解读(VLDB 2021) ...

  3. Fauce:Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation 论文解读(VLDB 2021)

    Fauce:Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation 论文解读(VLDB 2021) 本 ...

  4. ural 2021 Scarily interesting!(贪心)

    2021. Scarily interesting! Time limit: 1.0 secondMemory limit: 64 MB This year at Monsters Universit ...

  5. Gym 100507J Scarily interesting! (贪心)

    Scarily interesting! 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Description This y ...

  6. Dean and Schedule (URAL 2026)

    Problem A new academic year approaches, and the dean must make a schedule of classes for first-year ...

  7. 中庸之道(codevs 2021)

    题目描述 Description 给定一个长度为N的序列,有Q次询问,每次询问区间[L,R]的中位数. 数据保证序列中任意两个数不相同,且询问的所有区间长度为奇数. 输入描述 Input Descri ...

  8. Towers of Hanoi Strike Back (URAL 2029)

    Problem The Tower of Hanoi puzzle was invented by French mathematician Édouard Lucas in the second h ...

  9. URAL 1260 Nudnik Photographer(递推)

    题目链接 题意 : 给你1到n这n个数,排成一排,然后1放在左边最开始,剩下的数进行排列,要求排列出来的数列必须满足任何两个相邻的数之间的差不能超过2,问你有多少种排列 思路 : 对于dp[n], n ...

随机推荐

  1. 阿里云ecs不同网段内网互通

    建立ClassicLink连接 官方文档:https://help.aliyun.com/document_detail/65413.html?spm=a2c4g.11186623.2.12.16c9 ...

  2. IIs发布的项目无法打开问题

    1/查看一下ISAPI筛选器,是否存在2.0,4.0,若缺少东西,就从新安装一下iis,存在某些程序没有被勾选,一般是asp.net3.5,asp.net4.0

  3. Vs2019 C# .net core 将证书添加到受信任的根证书存储失败,出现以下错误:访问控制列表(ACL)结构无效

    https://www.cnblogs.com/xiyuan/p/10632579.html 使用 vs2017 创建一个 ASP.NET Core Web 应用程序 -> Ctrl + F5 ...

  4. Https的作用

    在普通的网络环境下,HTTP请求存在DNS劫持.运营商插入广告.数据被窃取,正常数据被修改等安全风险.使用HTTPS协议可以保证数据传输的安全性. Https的作用:    内容加密 建立一个信息安全 ...

  5. JS基础_构造函数修改

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. datagrid行内编辑

    编辑属性 :editor: { type: 'text'} $('#listShow').datagrid({ height : 478, pagesize : 20, pageList : [20, ...

  7. Kinect for Windows SDK开发入门(七):骨骼追踪基础 下

    http://www.cnblogs.com/yangecnu/archive/2012/04/09/KinectSDK_Skeleton_Tracking_Part2.html 上一篇文章用在UI界 ...

  8. 搭建配置私服-nexus ,Maven中的使用——3

    1. 下载nexus包,将bin目录添加到PATH路径下去   2. 修改: bin/jsw/conf 下面的wrapper.conf文件: 修改java命令绝对路径   修改之后:   3.  进入 ...

  9. Java 基础 线程的Runnable接口 /线程的同步方法 /同步代码块

    笔记: /**通过 Runnable接口来实现多线程 * 1. 创建一个实现runnable 接口的类 * 2. 在类中实现接口的run() 抽象方法 * 3. 创建一个runnable 接口实现类的 ...

  10. linux实操_shell系统函数

    basename函数: 功能:返回完整路径最后/的后面部分,常用于获取文件名. 基本语法: basename 路径 后缀 不加后缀:运行后 加后缀:运行后 dirname函数: 功能:返回完整路径最后 ...