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. 题解 P3369 【【模板】普通平衡树】

    在网上某篇神奇的教程和@codesonic 大佬的标程帮助下,我又肝完了Leafy Tree,跑过来写篇题解(好像以前写过一篇?) 什么是Leafy Tree? Leafy Tree由两种节点组成:辅 ...

  2. Python学习第二天-编写三级菜单

    编写三级菜单:1. 运行程序输出第一级菜单2. 选择一级菜单某项,输出二级菜单,同理输出三级菜单3. 菜单数据保存在文件中4. 让用户选择是否要退出5. 有返回上一级菜单的功能 # Author: z ...

  3. Qt之自定义布局管理器(QFlowLayout)

    简述 QFlowLayout,顾名思义-流布局,实现了处理不同窗口大小的布局.根据应用窗口的宽度来进行控件放置的变化. 具体实现要求不再赘述,请参考前两节内容. 简述 实现 效果 源码 实现 QFlo ...

  4. Postman(API & HTTP请求调试插件)

    简述 Postman是一个Chrome扩展,提供功能强大的Web API & HTTP请求调试.它能够发送任何类型的HTTP 请求(GET.HEAD.POST.PUT..),附带任何数量的参数 ...

  5. (六)storm-kafka源代码走读之PartitionManager

    PartitionManager算是storm-kafka的核心类了,如今開始简单分析一下.还是先声明一下,metric部分这里不做分析. PartitionManager主要负责的是消息的发送.容错 ...

  6. RvmTranslator7.1

    RvmTranslator7.1 eryar@163.com RvmTranslator can translate the RVM file exported by AVEVA Plant(PDMS ...

  7. angularjs 路由 ngRoute tab切换

    <!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...

  8. django 笔记7 多对多

    多对多 方法一 :双外键关联 自定义关系表 自定义 class Host(models.Model): nid = models.AutoField(primary_key=True) hostnam ...

  9. Dictionaries

    A dictionary is like a list, but more general. In a list, the indices have to be integers; in a dict ...

  10. 微信公众平台开发学习笔记2--获取access token

    access_token是公众号的全局唯一票据,公众号调用各接口时都需使用access_token.获取的access_token过期时间为2小时.获取access token具体说明请参考官方文档. ...