Description

There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player.

Find the way to distribute cards such that the sum of values written of the cards will be equal for each player. It is guaranteed that it is always possible.

Input

The first line of the input contains integer n (2 ≤ n ≤ 100) — the number of cards in the deck. It is guaranteed that n is even.

The second line contains the sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ 100), where ai is equal to the number written on the i-th card.

Output

Print n / 2 pairs of integers, the i-th pair denote the cards that should be given to the i-th player. Each card should be given to exactly one player. Cards are numbered in the order they appear in the input.

It is guaranteed that solution exists. If there are several correct answers, you are allowed to print any of them.

Examples
input
6
1 5 7 4 4 3
output
1 3
6 2
4 5
input
4
10 10 10 10
output
1 2
3 4
Note

In the first sample, cards are distributed in such a way that each player has the sum of numbers written on his cards equal to 8.

In the second sample, all values ai are equal. Thus, any distribution is acceptable.

这个,从大到小排序,然后取头尾就行

#include<bits/stdc++.h>
using namespace std;
int n,m;
struct P
{
int i,num;
}He[105];
bool cmd(P x,P y)
{
return x.num<y.num;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>He[i].num;
He[i].i=i;
}
sort(He+1,He+n+1,cmd);
for(int i=1;i<=n/2;i++)
{
cout<<He[i].i<<" "<<He[n-i+1].i<<endl;
}
return 0;
}

  

Codeforces Round #364 (Div. 2) A的更多相关文章

  1. Codeforces Round #364 (Div. 2)

    这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无 ...

  2. Codeforces Round #364 (Div.2) D:As Fast As Possible(模拟+推公式)

    题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...

  3. Codeforces Round #364 (Div.2) C:They Are Everywhere(双指针/尺取法)

    题目链接: http://codeforces.com/contest/701/problem/C 题意: 给出一个长度为n的字符串,要我们找出最小的子字符串包含所有的不同字符. 分析: 1.尺取法, ...

  4. 树形dp Codeforces Round #364 (Div. 1)B

    http://codeforces.com/problemset/problem/700/B 题目大意:给你一棵树,给你k个树上的点对.找到k/2个点对,使它在树上的距离最远.问,最大距离是多少? 思 ...

  5. Codeforces Round #364 (Div. 2) B. Cells Not Under Attack

    B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  6. Codeforces Round #364 (Div. 2) Cells Not Under Attack

    Cells Not Under Attack 题意: 给出n*n的地图,有给你m个坐标,是棋子,一个棋子可以把一行一列都攻击到,在根据下面的图,就可以看出让你求阴影(即没有被攻击)的方块个数 题解: ...

  7. Codeforces Round #364 (Div. 2) Cards

    Cards 题意: 给你n个牌,n是偶数,要你把这些牌分给n/2个人,并且让每个人的牌加起来相等. 题解: 这题我做的时候,最先想到的是模拟,之后码了一会,发现有些麻烦,就想别的方法.之后发现只要把它 ...

  8. Codeforces Round #364 (Div. 2)->A. Cards

    A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  9. Codeforces Round #364 (Div. 2) E. Connecting Universities

    E. Connecting Universities time limit per test 3 seconds memory limit per test 256 megabytes input s ...

  10. Codeforces Round #364 (Div. 2) C.They Are Everywhere

    C. They Are Everywhere time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

随机推荐

  1. 2.2synchronized同步语句块

    使用synchronized虽然能够避免不同步的现象出现,但是也会出现弊端,比如代码执行时间过长,那么其他线程就必须等待该线程执行完毕释放锁之后才能拿到锁. 面对这种问题可以使用同步代码块来解决. 2 ...

  2. cmdb1--介绍

    背景:现在运维管理服务器多数使用Excel表来维护,而且是多人来维护,造成信息不统一,所以要将信息入库,并方便后续的批量操作 1.cmdb主要分3块: a.采集信息程序 b.API提供接口 c.后台管 ...

  3. 二 Flask快速入门

    1: 外部可访问的服务器: 如果你运行了这个服务器,你会发现它只能从你自己的计算机上访问,网络中其它任何的地方都不能访问.在调试模式下,用户可以在你的计算机上执行任意 Python 代码.因此,这个行 ...

  4. python 基础 操作文件和目录

    获得当前目录路径 :os.getcwd() 返回指定目录下的所有文件和目录名:os.listdir() 删除一个文件:os.remove(filename) 删除多个空目录 :os.removefir ...

  5. shell入门-awk-2

    awk的条件操作符 ///显示第一段有root的行 [root@wangshaojun ~]# awk -F ':' '$1=="root"' 1.txtroot:x:0:0:ro ...

  6. centos7安装与配置ansible

    此次测试总共有三台机,分别如下: ansible服务器:10.0.0.20 client01:10.0.0.21 client02:10.0.0.22 一.安装ansible 1. python版本需 ...

  7. 创建sharepoint网站

    1.首先打开管理中心 输入用户名和密码(默认是本机的管理员名称及密码) 在“应用程序管理”选择“管理WEB应用程序” 新建应用程序 选择一个没有占用的端口,选择允许匿名访问 数据库名称一般为WSS_C ...

  8. 基本算法思想之递推算法思想(C++语言描述)

    递推算法是非常常用的算法思想,在数学计算等场合有着广泛的应用.递推算法适合有明显公式规律的场合. 递推算法基本思想 递推算法是一种理性思维莫斯的代表,根据已有的数据和关系,逐步推到而得到结果.递推算法 ...

  9. Angular07 路由的工作流程、路由参数、子路由、利用路由加载模块、模块懒加载???

    1 Angular路由的工作流程 用户在浏览器输入一个URL -> Angular将获取到这个URL并将其解析成一个UrlTree实例 -> Angular会到路由配置中去寻找并激活与Ur ...

  10. 3、perl进阶

    1.条件判断与循环结构(if (unless)  while(until) for foreach next last redo) if (unless)  关系运算符: 数字关系运算符(>,& ...