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.

分析:水题,见代码。

 /*************************************************************************
> File Name: cfC.cpp
> Author:
> Mail:
> Created Time: 2016年08月08日 星期一 13时42分35秒
************************************************************************/ #include<iostream>
#include<bits/stdc++.h>
using namespace std;
int a[],vis[]; int main()
{
int n;
cin >> n;
int sum = ;
for(int i = ; i <= n; i++)
{
cin >> a[i];
sum += a[i];
}
memset(vis,,sizeof(vis));
int nn = n /;
sum = sum / nn;
for(int i = ; i <= n; i++)
{
for(int j = i+; j<= n; j++)
{
if(a[i] + a[j] == sum && !vis[i] && !vis[j])
{
printf("%d %d\n",i,j);
vis[i] = ;
vis[j] =;
}
}
}
return ;
}

Codeforces 701A. Cards(水)的更多相关文章

  1. CodeForces 701A Cards

    直接看示例输入输出+提示 1. 统计所有数的和 sum,然后求 sum/(n/2) 的到一半数的平均值 6 1 5 7 4 4 3 ->1+5+7+4+4+3=24  分成3组 每组值为8 in ...

  2. codeforces 701A A. Cards(水题)

    题目链接: A. Cards 题意: 问两个数的和相同,怎么组合; AC代码: #include <iostream> #include <cstdio> #include & ...

  3. Codeforces Round #356 (Div. 2) A. Bear and Five Cards 水题

    A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little be ...

  4. Codeforces Round #304 (Div. 2) C. Soldier and Cards 水题

    C. Soldier and Cards Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546 ...

  5. codeforces 680A A. Bear and Five Cards(水题)

    题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...

  6. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  7. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  8. CodeForces 705B (训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2) ...

  9. codeforces hungry sequence 水题

    题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...

随机推荐

  1. Linux下库文件的设置 (/usr/bin/ld: cannot find -lxxx 的解决办法)

    在软件编译过程中,经常会碰到类似这样的编译错误: /usr/bin/ld: cannot find -lhdf5 这表示找不到库文件 libhdf5.so,若是其它库文件,则是 cannot find ...

  2. Python学习简单练习-99乘法表

    __author__ = 'ZFH'#-*- coding:utf-8 -*-for i in range(10): #外层循环,range(10),1-9 for j in range(1,i+1) ...

  3. js 判断是否滚动到底部

    $(window).scroll(function(){ var scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置 ...

  4. 调用Windows属性窗口

    简述 在Windows系统下.可以通过:右键 -> 属性,来查看文件/文件夹对应的属性信息,包括:常规.安全.详细信息等. 简述 共有类型 共有类型 首先,需要包含头文件: #include & ...

  5. unix中文件I/O

    在unix中可用的文件I/O函数包含打开文件,读文件,写文件等. Unix系统中的大多数文件I/O须要用到5个函数:open,read,write,lseek,close. 这里要说明的是read,w ...

  6. bzoj3931: [CQOI2015]网络吞吐量(spfa+网络流)

    3931: [CQOI2015]网络吞吐量 题目:传送门 题解: 现在有点难受....跳了一个多钟...菜啊... 题意都把做法一起给了....最短路+网路流啊. 不想说话...记得开long lon ...

  7. ckeidtor编辑器添加图片上传功能

    1.ckeditor默认没有上传图片功能,只能通过Url显示图片,图下图 2.首先说明,ckeditor是有上传功能的,只是隐藏了,需要通过配置让它显示 找到ckeditor/plugins/imag ...

  8. <Sicily>Pythagorean Proposition

    一.题目描述 One day, WXYZ got a wooden stick, he wanted to split it into three sticks and make a right-an ...

  9. 日常基础—————echo,print,print_r,var_dump的区别

    1.echo   函数输出一个或多个字符串. 代码: header("Content-Type:text/html; charset=utf-8"); echo "你好” ...

  10. plsql 中如何清除曾经登录过的用户名

    tools(工具)---> preferences(首选项) ---> login history(登录历史) ---> history(历史) ---> 把你想要删除的删除