CF1656A.Good Pairs

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array a1,a2,,ana_1, a_2, \ldots, a_n of positive integers. A good pair is a pair of indices (i,j)(i, j) with 1i,jn1 \leq i, j \leq n such that, for all 1kn1 \leq k \leq n , the following equality holds:

$$ |a_i - a_k| + |a_k - a_j| = |a_i - a_j|, $$ where $|x|$ denotes the absolute value of $x$ .</p><p>Find a good pair. Note that $i$ can be equal to $j$$$.

输入格式

The input consists of multiple test cases. The first line contains a single integer tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases. Description of the test cases follows.

The first line of each test case contains an integer nn ( 1n1051 \leq n \leq 10^5 ) — the length of the array.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1091 \leq a_i \leq 10^9 ) where aia_i is the ii -th element of the array.

The sum of nn for all test cases is at most 21052 \cdot 10^5 .

输出格式

For each test case, print a single line with two space-separated indices ii and jj which form a good pair of the array. The case i=ji=j is allowed. It can be shown that such a pair always exists. If there are multiple good pairs, print any of them.

输入输出样例

  • 输入#1

    3
    3
    5 2 7
    5
    1 4 2 2 3
    1
    2

    输出#1

    2 3
    1 2
    1 1

说明/提示

In the first case, for i=2i = 2 and j=3j = 3 the equality holds true for all kk :

  • k=1k = 1 : a2a1+a1a3=25+57=5=27=a2a3|a_2 - a_1| + |a_1 - a_3| = |2 - 5| + |5 - 7| = 5 = |2 - 7| = |a_2-a_3| ,
  • k=2k = 2 : a2a2+a2a3=22+27=5=27=a2a3|a_2 - a_2| + |a_2 - a_3| = |2 - 2| + |2 - 7| = 5 = |2 - 7| = |a_2-a_3| ,
  • k=3k = 3 : a2a3+a3a3=27+77=5=27=a2a3|a_2 - a_3| + |a_3 - a_3| = |2 - 7| + |7 - 7| = 5 = |2 - 7| = |a_2-a_3| .
首页