CF701A.Cards
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
牌组中有 n 张牌(n 为偶数)。每张牌上写有一个正整数。将有 n/2 人参与一场新的纸牌游戏。游戏开始时,每位玩家获得两张牌,且每张牌恰好分给一位玩家。
请找出一种分牌方式,使得每位玩家所持两张牌上的数字之和均相等。题目保证这样的分配方式一定存在。
输入格式
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 _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 100), where a__i is equal to the number written on the i-th card.
输入的第一行包含一个整数 n(2≤n≤100)—— 表示牌组中的卡片数量。保证 n 是偶数。
第二行包含一个由 n 个正整数 a1,a2,…,an(1≤ai≤100)组成的序列,其中 ai 表示第 i 张卡片上所写的数字。
输出格式
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.
输出 n/2 对整数,其中第 i 对表示应分发给第 i 位玩家的两张牌。每张牌必须且仅能分发给一位玩家。牌的编号按其在输入中出现的顺序确定。
保证存在解。若存在多个正确答案,输出任意一个即可。
输入输出样例
输入#1
6 1 5 7 4 4 3
输出#1
1 3 6 2 4 5
输入#2
4 10 10 10 10
输出#2
1 2 3 4
说明/提示
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 a__i are equal. Thus, any distribution is acceptable.
在第一个样例中,卡片的分配方式使得每位玩家所持卡片上的数字之和均为 8。
在第二个样例中,所有值 ai 均相等。因此,任意分配方式均可接受。
输入解题思路,AI测评打分。不知道怎么写?