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. python基础9 (迭代器、生成器)

    1.可迭代对象 迭代:将某个数据集内的数据“一个挨着一个的取出来” 可迭代协议:可以被迭代要满足的要求,即内部含有__iter__()方法 可迭代的类型:字符串.列表.元组.字典.集合特点:惰性运算 ...

  2. 关于buffer和cache的区别

    1. Cache:缓存区,是高速缓存,是位于CPU和主内存之间的容量较小但速度很快的存储器,因为CPU的速度远远高于主内存的速度,CPU从内存中读取数据需等待很长的时间,而  Cache保存着CPU刚 ...

  3. ZOJ 3369 Saving Princess

    Saving Princess Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...

  4. 我有一个idea,但是没有钱,又没技术怎么办?

    我想你还少讲一件事,就是同时如果你也没什么明确的商业计划,恭喜,那你有机会成为马云第二,因为他曾说过自己的成功要素就是「没钱」.「不懂技术」.「没有计划」,要是这么刚好让你从事互联网产业,我看不出三年 ...

  5. Android源代码解析之(十三)--&gt;apk安装流程

    转载请标明出处:一片枫叶的专栏 上一篇文章中给大家分析了一下android系统启动之后调用PackageManagerService服务并解析系统特定文件夹.解析apk文件并安装的过程,这个安装过程实 ...

  6. maven的setting设置

    maven的setting设置,settings.xml文件,多写了几个仓库的地址: <?xml version="1.0" encoding="UTF-8&quo ...

  7. hadoop-11-ambari-server安装

    hadoop-11-ambari-server安装 #ambari 安装yum install ambari-servercd mysql-5.7.18/cp mysql-connector-java ...

  8. 利用艺术家的整数ID映射将标签转换为向量

    <strong><span style="font-size:18px;">/*** * @author YangXin * @info Mapper选择艺 ...

  9. 黑马程序猿-----Java之你不得不知道的排序

    ------<a href="http://www.itheima.com" target="blank">Java培训.Android培训.iOS ...

  10. BAPC2014 K&amp;&amp;HUNNU11591:Key to Knowledge(中途相遇法)

    题意: 有N个学生.有M题目 然后相应N行分别有一个二进制和一个整数 二进制代表该同学给出的每道题的答案.整数代表该同学的答案与标准答案相符的个数 要求推断标准答案有几个,假设标准答案仅仅有一种.则输 ...