Scarily interesting! (URAL - 2021)
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 |
5 1 |
题解:题意就是在已经知道那个队会赢得前提下,又知道了每个队员会得的分数,怎么让他们之前的对战变得更有悬念。我理解的就是由败转变胜利就是一种悬念的方式。所以排下序,让输的那一队先派出得分多的,让赢得那一队先派出得分少的,尽可能让悬念大一些。
#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)的更多相关文章
- 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 ...
- 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) ...
- 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) 本 ...
- ural 2021 Scarily interesting!(贪心)
2021. Scarily interesting! Time limit: 1.0 secondMemory limit: 64 MB This year at Monsters Universit ...
- Gym 100507J Scarily interesting! (贪心)
Scarily interesting! 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Description This y ...
- Dean and Schedule (URAL 2026)
Problem A new academic year approaches, and the dean must make a schedule of classes for first-year ...
- 中庸之道(codevs 2021)
题目描述 Description 给定一个长度为N的序列,有Q次询问,每次询问区间[L,R]的中位数. 数据保证序列中任意两个数不相同,且询问的所有区间长度为奇数. 输入描述 Input Descri ...
- Towers of Hanoi Strike Back (URAL 2029)
Problem The Tower of Hanoi puzzle was invented by French mathematician Édouard Lucas in the second h ...
- URAL 1260 Nudnik Photographer(递推)
题目链接 题意 : 给你1到n这n个数,排成一排,然后1放在左边最开始,剩下的数进行排列,要求排列出来的数列必须满足任何两个相邻的数之间的差不能超过2,问你有多少种排列 思路 : 对于dp[n], n ...
随机推荐
- [Vue]axios 发出请求的config
这些是用于发出请求的可用配置选项. 只有url是必需的. 如果未指定方法,请求将默认为GET. { // `url`是将用于请求的服务器URL url: '/user', // `method`是发出 ...
- .NET Core使用swagger遇到的坑
今天突然点开写好的接口,突然发现展开时同时展开了两个接口.如图 我点这两个接口任意一个,这两个都会同时展开或折叠. 原因是他们actinName相同,虽然在vs里面只要http方法不同,action是 ...
- springboot mvc自动配置(二)注册DispatcherServlet到ServletContext
所有文章 https://www.cnblogs.com/lay2017/p/11775787.html 正文 上一篇文章中,我们看到了DispatcherServlet和DispatcherServ ...
- nginx分割日志
实现nginx日志按照时间分割存储 backups_log.sh #设置log日志的存储地址 LOG_PATH=/home/soft/nginx/logs #设置历史日志的存储地址 HISTORY_L ...
- 9.Redis的Java客户端Jedis
Redis的Java客户端Jedis Jedis所需jar包 commons-pool-1.6.jar jedis-2.1.0.jar 1.Jedis常用操作(jedis中的api 和 我们在 l ...
- selenium重定向新窗口
1.跳转新窗口 # 浏览器跳转新窗口后,selenium绑定新窗口 print('页面跳转后重新绑定selenium.') time.sleep(3) search_window = driver.c ...
- JAVA处理数字与中文数字互转(最大处理数字不超过万兆即:9999999999999999.9999)
package practice; import java.util.Arrays; /** * 数字与中文数字互转(最大处理数字不超过万兆即:9999999999999999.9999) * @au ...
- javaWeb文件上传与下载
文件上传与下载在项目中运用的使用频率很大 今天也花时间整理了一下 多文件上传图片回显 和文件下载 1.多文件上传 这里会涉及到几个属性 fileSizeThreshold:缓冲区文件的大小 如果上传 ...
- Linux命令——mkdir、rmdir
mkdir -p:递归创建目录 -v:每次创建新目录都显示信息 -m:直接指定权限(不使用默认umask演算的那个) [root@51cto /]# mkdir /a/b/c -pv mkdir: c ...
- idou老师教你学Istio 22 : 如何用istio实现调用链跟踪
大家都知道istio可以帮助我们实现灰度发布.流量监控.流量治理等一些功能. 每一个功能都帮助我们在不同场景中实现不同的业务.那么其中比如流量监控这种复杂的功能Istio是如何让我们在不同的应用中实现 ...