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 ...
随机推荐
- YAML 语言格式
1. 认识 YAML YAML(Yet Another Markup Language)语言(发音 /ˈjæməl/ )是一个类似 XML.JSON 的标记性语言.YAML 强调以数据为中心,并不是以 ...
- (错误) Eclipse使用Maven创建Web时错误
转自:http://blog.csdn.net/afgasdg/article/details/12757433 问题描述: 使用Eclipse自带的Maven插件创建Web项目时报错: Could ...
- Asp.Net Core Linux环境下 找不到配置文件、静态文件的问题
直接发布会找不到配置文件,和静态文件.需要先cd到项目文件夹,然后在发布.
- Keras 笔记
1. 从 meta 模型恢复graph, 修改node 并保存 from __future__ import absolute_import from __future__ import div ...
- 整屏纵向切换超出整屏内容纵向滚动 解决办法-fullpage
这个问题我也是研究了好久,百度了很多办法,swiper我始终没有找到合适的解决办法,所以我放弃了swiper,改用fullpage. fullpage里面有个scrollOverflow的属性: 并且 ...
- shell取消键盘回显
使用下面这个命令取消回显 stty -echo 使用下面这个命令打开回显 stty echo
- fcrackzip破解zip密码
kail系统里有fcrackzip工具,可以对设置密码的压缩包zip直接进行破解,不用字典,直接进行暴力破解. fcrackzip 所用到的参数介绍如下:-b 表示暴力破解-c 表示暴力破解中使用的字 ...
- Vue获取数据渲染完成事件
主要代码是这两坨 this.nextTick(function(){ alert('数据已经更新') }); this.$nextTick(function(){ alert('v-for渲染已经完成 ...
- springboot 部署到tomcat,获取根路径问题。空格变为%20
String path = ResourceUtils.getURL("classpath:").getPath()+"static/upload"; Syst ...
- 学习笔记:Python序列化常用工具及性能对比
什么叫序列化?简单来讲就是将内存中的变量数据转而存储到磁盘上或是通过网络传输到远程. 反序列化是指:把变量数据从序列化的对象重新读到内存里. 下面我们一起来看看,python里面序列化常用的json. ...