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. Laravel 出现"RuntimeException inEncrypter.php line 43: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."问题的解决办法

    如果输入命令:php artisan key:generate 还是报错 那就要从别的项目里复制一个key到.env中,然后再运行命令:composer update和php artisan key: ...

  2. br_netfilter 模块开机自动方法

    环境 cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 在/etc/sysctl.conf中添加: net.bridge.bri ...

  3. Tomcat日志备份脚本

    #!/bin/bash #Author:fansik #Description:backup tomcat logs #Date:-- directory=/usr/local/tomcat/logs ...

  4. Computer Information

    Lab: lxw@lxw-PC:python$ df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda7 190G .4G 175G % / none .0K .0K % /sys/ ...

  5. LeetCode:学生的出勤记录|【551】

    LeetCode:学生的出勤记录|[551] 题目描述 给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : P ...

  6. dataTables的用法

    原地址:http://blog.csdn.net/mickey_miki/article/details/8240477 1.DataTables的默认配置 $(document).ready(fun ...

  7. docker devise相关错误

    rake aborted!Devise.secret_key was not set. Please add the following to your Devise initializer: con ...

  8. ES6 随记(2)-- 解构赋值

    上一章请见: 1. ES6 随记(1)-- let 与 const 3. 解构赋值 a. 数组的解构赋值 let [a1, b1, c1] = [1, 2, 3]; console.log(a1, b ...

  9. Qt浅谈之二十六图片滑动效果

    一.简介 博客中发现有作者写的仿360的代码,觉得其中图片滑动的效果很有意思,特提取其中的代码.并加上类似mac的画面移动的动画效果. 二.详解 1.代码一:界面滑动(QWidget) (1)slid ...

  10. css异步加载

    <link rel="preload" href="mystyles.css" as="style" onload="thi ...