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. 一篇文章彻底搞懂异步,同步,setTimeout,Promise,async

    之前翻看别的大佬的博客看到了关于setTimeout,promise还有async执行顺序的文章.观看了几篇之后还是没有怎么看懂,于是自己开始分析代码,并整理了此文章,我相信通过此文章朋友们能对异步同 ...

  2. ARM微控制器与嵌入式系统

    个牛人在ARM实现嵌入式系统的过程 第一章  概览 1.1课程概览 认识ARM嵌入式系统(什么是ARM?什么是嵌入式系统?) 备战智能车 在科技活动中玩起来 积累计算机.电路基础知识 1.2如何学好嵌 ...

  3. js入门第一篇

    简介:JavaScript 运行在客户端(浏览器)是一种客户端语言,javascript的引擎被称为JavaScript引擎,为浏览器的一部分广泛用于客户端的脚本语言 应用场景:网页特效, 服务端开发 ...

  4. The openssl extension is missing, which means that secure HTTPS transfers are impossible

    执行命令:curl -sS https://getcomposer.org/installer | php报错如下Some settings on your machine make Composer ...

  5. vi/vim常用按键

    最近这段时间坚持了vim的使用,我在我的IDEA里面加了一个插件,可以支持vim. 然后不管是IDEA还是Vim都有自己的按键,而且都很好用,所以我就总结下在IDEA下的vim使用命令 当然,都是原生 ...

  6. MySQL菜鸟入门“秘籍”

    一.MySQL简介 1.什么是数据库 ? 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,它产生于距今六十多年前,随着信息技术和市场的发展,特别是二十世纪九十年代以后,数据管理不 ...

  7. Linux学习笔记(十)shell基础:历史命令、命令补全、输出重定向、输出重定向

    一.历史命令 history [选项] [历史命令保存文件] -c 清空历史命令 -w 吧缓存中的历史命令写入历史命令保存文件~/.bash_history中 系统会默认将上次注销登录(正确退出)之前 ...

  8. 微信中浏览器支持input调用摄像头和只能上传图片

    <input type="file" capture="camera" accept="image/*" />

  9. Octave基本语法

    基本运算 octave:3> 5+6 ans = 11 octave:4> 3-2 ans = 1 octave:5> 8*9 ans = 72 octave:6> 8/4 a ...

  10. C# 调用 python3

    1.C# 调用python 本质上是使用命令行运行python 1.1 C# 使用命令行 program.cs using System; using System.Diagnostics; usin ...