A. Cards
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

题意:n个数 (n为偶数) 两个配对组合  使得每组的和相同 (数据一定满足条件) 输出n/2对组合的两个数的位置

题解:结构体排序 头尾配对输出各个的位置

 //code  by drizzle
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
int n;
struct node
{
int x;
int pos;
}N[];
bool cmp(struct node aa,struct node bb)
{
return aa.x<bb.x;
}
int main()
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&N[i].x);
N[i].pos=i;
}
sort(N+,N+n+,cmp);
for(int i=;i<=n/;i++)
printf("%d %d\n",N[i].pos,N[n+-i].pos);
return ;
}

最新文章

  1. Sql Service 的job作业新建过程
  2. OBS-Studio二次开发记录
  3. ecshop 后台分页功能
  4. RaspberryPi uart
  5. lintcode :二叉树的最大深度
  6. 扯扯淡,写个更快的memcpy
  7. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(5)-EF增删改查by糟糕的代码
  8. OpenStack对象存储——Swift
  9. Java Calendar获取年、月、日、时间
  10. fedora 下安装 文泉驿正黑体
  11. object - c 在URL中截取特定参数的值
  12. 关于easyui隐藏后数据不能刷新??
  13. AD服务无法启动
  14. shell脚本:通过域名获取证书的过期时间
  15. 均方根误差(RMSE)与平均绝对误差(MAE)
  16. asp.net button控件 使用JS的 disabled
  17. Oracle表的查询(一)
  18. git和gulp使用
  19. 1050: 贝贝的ISBN号码(isbn)
  20. c++ 匹配A容器中最先出现的b容器中的元素,返回iterator,(find_first_of)

热门文章

  1. 该网页无法正常运作 目前无法处理此请求HTTP ERROR 500?
  2. javascript的基本类型和引用类型
  3. ATM-lib-common
  4. 绘制字符串:imagestring()
  5. sed速查手册
  6. Tame Me【驯服我】
  7. HDU - 6514 Monitor(二维差分)
  8. 用私有构造器或者枚举类型强化Singleton属性
  9. 数据库sql中distinct用法注意事项
  10. Proguard returned with error code 1. See console