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. [python学习笔记] py2exe 打包

    遇坑 之前经过折腾,pyinstaller打包文件可以在别的windows7上运行.但是,mfk, 客户说是xp系统.崩溃 使用pyinstaller各种折腾,打包出来的依然是不是有效的win32程序 ...

  2. java 基础语法 2

    一.语句

  3. E - 今年暑假不AC HDU - 2037

    "今年暑假不AC?"  "是的."  "那你干什么呢?"  "看世界杯呀,笨蛋!"  "@#$%^&* ...

  4. 巧用Mono.Cecil反射加载类型和方法信息

    最近在做服务的细粒度治理,统一管理所有服务的方法.参数.返回值信息.方便后续的各个模块之间的对接和协作. 目前系统中所有的服务,管理到接口契约粒度,即服务接口声明和服务接口实现.要做服务的细粒度治理: ...

  5. Quartz源码——scheduler.start()启动源码分析(二)

    scheduler.start()是Quartz的启动方式!下面进行分析,方便自己查看! 我都是分析的jobStore 方式为jdbc的SimpleTrigger!RAM的方式类似分析方式! Quar ...

  6. 第4章 同步控制 Synchronization ----Interlocked Variables

    同步机制的最简单类型是使用 interlocked 函数,对着标准的 32 位变量进行操作.这些函数并没有提供"等待"机能,它们只是保证对某个特定变量的存取操作是"一个一 ...

  7. hdu 5952 连通子图

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  8. Doing Homework again

     Doing Homework again Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  9. Next Greater Element I

    You are given two arrays (without duplicates) nums1 and nums2 where nums1's elements are subset of n ...

  10. System.Object简介

    Object中的公共方法解释: 公共方法: Equals: public class Object { public virtual Boolean Equals(Object obj) { //如果 ...