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 oi and ri, 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

input output
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
 
 
 
两个队伍比赛,每个队伍有n个人,每个人的得分为0-6,总得分多的队伍赢。
求两个队伍怎样安排上场顺序,尽量让悬念保持到最后。
思路:赢的一方从小到大输出,输的一方从大到小输出。
 #include <bits/stdc++.h>
using namespace std; const int MAXN = ; vector<int> vt1[];
vector<int> vt2[]; vector<int> vt3;
vector<int> vt4; int main()
{
int n;
int i;
int a, b;
vector<int>::iterator it1, it2;
int sum1, sum2; while (~scanf("%d", &n)) {
for (i = ; i <= ; ++i) {
vt1[i].clear();
vt2[i].clear();
}
vt3.clear();
vt4.clear();
sum1 = ;
sum2 = ;
for (i = ; i <= n; ++i) {
scanf("%d", &a);
vt1[a].push_back(i);
sum1 += a;
}
for (i = ; i <= n; ++i) {
scanf("%d", &b);
vt2[b].push_back(i);
sum2 += b;
}
// printf("debug 1\n");
for (i = ; i <= ; ++i) {
it1 = vt1[i].begin();
it2 = vt2[i].begin();
if (vt1[i].size() < vt2[i].size()) {
while (it1 < vt1[i].end()) {
printf("%d %d\n", *it1++, *it2++);
}
while (it2 < vt2[i].end()) {
vt4.push_back(*it2++);
}
} else {
// printf("debug 3\n");
while (it2 < vt2[i].end()) {
printf("%d %d\n", *it1++, *it2++);
}
while (it1 < vt1[i].end()) {
vt3.push_back(*it1++);
}
}
}
// printf("debug 2\n"); if (sum1 > sum2) {
it1 = vt3.begin();
it2 = vt4.end() - ;
while (it1 < vt3.end()) {
printf("%d %d\n", *it1++, *it2--);
}
} else {
it1 = vt3.end() - ;
it2 = vt4.begin();
while (it2 < vt4.end()) {
printf("%d %d\n", *it1--, *it2++);
}
} } return ;
}

ps:自己没想到这样做啊,

我的思路是让双方的分差越小越好,但是不知道这样做对不,写起来也比较复杂。

ural 2021 Scarily interesting!(贪心)的更多相关文章

  1. URAL 2021 Scarily interesting! (贪心+题意)

    题意:给定两个队伍的每个人的得分,让你安排怎么比赛才能使得观众知道冠军的时间最长. 析:贪心,很简单,就是先开始总分高的先出最差劲的,总分低的先出最厉害的,这个题当时实在是读的不明白啊,WA了好多次. ...

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

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

  3. J - Scarily interesting! URAL - 2021

    This year at Monsters University it is decided to arrange Scare Games. At the Games all campus gathe ...

  4. Scarily interesting! (URAL - 2021)

    Problem This year at Monsters University it is decided to arrange Scare Games. At the Games all camp ...

  5. ural 1303 Minimal Coverage(贪心)

    链接: http://acm.timus.ru/problem.aspx?space=1&num=1303 按照贪心的思想,每次找到覆盖要求区间左端点时,右端点最大的线段,然后把要求覆盖的区间 ...

  6. URAL 1995 Illegal spices 贪心构造

    Illegal spices 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1995 Description Jabba: Han, m ...

  7. Ural 2070:Interesting Numbers(思维)

    http://acm.timus.ru/problem.aspx?space=1&num=2070 题意:A认为如果某个数为质数的话,该数字是有趣的.B认为如果某个数它分解得到的因子数目是素数 ...

  8. NEERC 2014, Eastern subregional contest

    最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...

  9. Contest 7.21(贪心专练)

    这一次都主要是贪心练习 练习地址http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#overview Problem APOJ 13 ...

随机推荐

  1. Python中何时使用断言(转)

    原文:http://blog.jobbole.com/76285/ 本文由 伯乐在线 - 贱圣OMG 翻译.未经许可,禁止转载!英文出处:python maillist.欢迎加入翻译小组. 这个问题是 ...

  2. Python3 面向对象(1)

    面向.概述 面向过程: 根据业务逻辑从上到下写垒代码面向过程的设计的核心是过程,过程即解决问题的步骤, 面向过程的设计就好比精心设计好一条流水线,考虑周全什么时候处理什么东西 优点: 极大降低了程序的 ...

  3. 关于handler内存泄露的问题

    在使用Handler更新UI的时候.我是这样写的: public class SampleActivity extends Activity { private final Handler mLeak ...

  4. Python基础-configparser和hashlib模块

    configparser模块 import configparser config = configparser.ConfigParser() #将配置写入到文件 config[', 'Compres ...

  5. oracle修改连接数后无法启动(信号量的问题)

    当oracle11g修改最大连接数后启动报如下错误时,需要调整linux的信号量的内核参数: ORA-27154: post/wait create failedCause: internal err ...

  6. ajax图片上传功能

    一.应用场景 当用户需要上传图片当做自己的头像时,预览的时候该图片需要在本地预览,不应该通过网络从服务器上取到之后预览 二.实现方法 1.方法1: 注释:给上传文件的input标签绑定一个change ...

  7. Python Variable Scope

    Python中的变量的作用域有时会让像我这样的初学者很头疼. 其实只需要掌握以下两点: 1. Python能够改变变量作用域的代码段是def.class.lamda;    而if/elif/else ...

  8. jquery 字符串转为json

    使用ajax从服务器拿到的数据,jquery总是认为是字符串,无法直接使用,可以通过下面代码转换: $.get("服务器路径", function(data) { data = e ...

  9. LeetCode:寻找数组的中心索引【668】

    LeetCode:寻找数组的中心索引[668] 题目描述 给定一个整数类型的数组 nums,请编写一个能够返回数组“中心索引”的方法. 我们是这样定义数组中心索引的:数组中心索引的左侧所有元素相加的和 ...

  10. problem-1003(恢复一下)

    问题: Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequenc ...