CF1656A.Good Pairs
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an of positive integers. A good pair is a pair of indices (i,j) with 1≤i,j≤n such that, for all 1≤k≤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 t ( 1≤t≤1000 ) — the number of test cases. Description of the test cases follows.
The first line of each test case contains an integer n ( 1≤n≤105 ) — the length of the array.
The second line of each test case contains n integers a1,a2,…,an ( 1≤ai≤109 ) where ai is the i -th element of the array.
The sum of n for all test cases is at most 2⋅105 .
输出格式
For each test case, print a single line with two space-separated indices i and j which form a good pair of the array. The case i=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=2 and j=3 the equality holds true for all k :
- k=1 : ∣a2−a1∣+∣a1−a3∣=∣2−5∣+∣5−7∣=5=∣2−7∣=∣a2−a3∣ ,
- k=2 : ∣a2−a2∣+∣a2−a3∣=∣2−2∣+∣2−7∣=5=∣2−7∣=∣a2−a3∣ ,
- k=3 : ∣a2−a3∣+∣a3−a3∣=∣2−7∣+∣7−7∣=5=∣2−7∣=∣a2−a3∣ .