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 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

Hint

/*
* @Author: lyuc
* @Date: 2017-04-30 16:02:54
* @Last Modified by: lyuc
* @Last Modified time: 2017-04-30 16:37:02
*/
/**
* 题意:两个队伍比赛,每次每队派一名怪兽出来,已知每个怪兽能获得分数,最后分数高的队伍获胜
* 为了比赛的悬念尽可能的留在最后,请你安排怪兽出场的顺序
*
* 思路:首先统计一下每个队伍的每个队伍的得分,肯定分数多的获胜,然后分数多的队伍从小到大输
* 出,分数少的从大到小输出
*/
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
struct node{
int id,val;
}a[],b[];
int n;
bool cmp1(node a,node b){
return a.val<b.val;
}
bool cmp2(node a,node b){
return a.val>b.val;
}
int res1,res2;
void init(){
res1=;
res2=;
}
int main(){
// freopen("in.txt","r",stdin);
init();
scanf("%d",&n);
for(int i=;i<n;i++){
a[i].id=i+;
scanf("%d",&a[i].val);
res1+=a[i].val;
}
for(int i=;i<n;i++){
b[i].id=i+;
scanf("%d",&b[i].val);
res2+=b[i].val;
}
if(res1>res2){
sort(a,a+n,cmp1);
sort(b,b+n,cmp2);
for(int i=;i<n;i++){
printf("%d %d\n",a[i].id,b[i].id);
}
}else{
sort(a,a+n,cmp2);
sort(b,b+n,cmp1);
for(int i=;i<n;i++){
printf("%d %d\n",a[i].id,b[i].id);
}
}
return ;
}

J - Scarily interesting! URAL - 2021的更多相关文章

  1. ural 2021 Scarily interesting!(贪心)

    2021. Scarily interesting! Time limit: 1.0 secondMemory limit: 64 MB This year at Monsters Universit ...

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

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

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

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

  4. Scarily interesting! (URAL - 2021)

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

  5. 2021蓝桥杯省赛B组(C/C++)E.路径【最短路DP】

    2021蓝桥杯省赛B组题目(C/C++)E.路径 最短路径, 因为变化情况比较多, 所以开始想的是深搜, 但是太慢了, 跑不出来, 后来就想着优化一下, 有的地方到另一个地方可能会考虑很多遍, 于是考 ...

  6. CSP J/S 初赛总结

    CSP J/S 初赛总结 2021/9/19 19:29 用官方答案估计 J 涂卡的时候唯一的一支 2B 铅笔坏了,只能用笔芯一个个涂 选择 \(-6\ pts\) 判断 \(-3\ pts\) 回答 ...

  7. NEERC 2014, Eastern subregional contest

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

  8. HDOJ-ACM1023(JAVA)

    题意:输入栈的大小,输出可能的出栈顺序的个数. 这道题,如果做了1022,那就只要在上面改改就行了, 第一想法是加上全排列-----结果是正确的,但是绝对会超时 验证性的实现了:(Time Limit ...

  9. UVA 583 分解质因数

    Webster defines prime as:prime (prim) n. [ME, fr. MF, fem. of prin first, L primus; akin to L prior] ...

随机推荐

  1. 一个完整的Node.js RESTful API

    前言 这篇文章算是对Building APIs with Node.js这本书的一个总结.用Node.js写接口对我来说是很有用的,比如在项目初始阶段,可以快速的模拟网络请求.正因为它用js写的,跟i ...

  2. Pycharm中如何加载多个项目?

    今天在使用Pycharm工具练习Python时遇到一个疑问:在已存有项目A工程的前提下如何新建另一个项目B,且两者并存? 基本操作步骤: 在File下拉项中选择"New Project&qu ...

  3. 读Zepto源码之IOS3模块

    IOS3 模块是针对 IOS 的兼容模块,实现了两个常用方法的兼容,这两个方法分别是 trim 和 reduce . 读 Zepto 源码系列文章已经放到了github上,欢迎star: readin ...

  4. S2_SQL_第四章

    1.使用EXISTS语句判断该数据库对象是否存在的语法: DROP TABLE IF EXISTS temp; 2. EXISTS作为WHERE语句的子查询: SELECT <字段>FRO ...

  5. .Net 内存对象分析

    在生产环境中,通过运行日志我们会发现一些异常问题,此时,我们不能直接拿VS远程到服务器上调试,同时日志输出的信息无法百分百反映内存中对象的状态,比如说我们想查看进程中所有的Socket连接状态.服务路 ...

  6. 经典算法研究系列:二、Dijkstra 算法初探

    July   二零一一年一月 本文主要参考:算法导论 第二版.维基百科. 一.Dijkstra 算法的介绍 Dijkstra 算法,又叫迪科斯彻算法(Dijkstra),算法解决的是有向图中单个源点到 ...

  7. VB.net shell、IO.File.Open、Process.Start、Shellexecute API 运用经验总结

    打开文件还有很多方法,但我了解到运用较多的是上面几种- -,为了防止以后忘记,先把了解到的写下来. 1.Shell 这个看了很多网页,最靠谱的运用方法: Shell("cmd.exe /c ...

  8. Linux 独立安装subversion-1.8.18

    一.所需软件包 1.apr-1.4.6.tar.gz 下载地址:http://apr.apache.org/   2.apr-util-1.4.1.tar.gz 下载地址:http://apr.apa ...

  9. Linux下将Apache(httpd)新增为系统服务及开机自启动

    1. 查看一下/etc/init.d/下是否存在httpd这个服务 ls /etc/init.d/ | grep httpd 如果没有执行下一步 2.将自己安装目录下的apachect1复制到该目录下 ...

  10. JavaScript实现常见算法面试题

    算法题目部分参照了<进军硅谷>这本书. github:https://github.com/qcer/Algo-Practice (如果你觉得有帮助,记得给个star,THS) 一.排序 ...