309275: CF1656A. Good Pairs
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Good Pairs
题意翻译
给定一个长度为 $n$ 的数列 $a$,请找出任意一个数对 $(i,j)$,满足: - $1\leqslant i,j\leqslant n$。 - $\forall 1\leqslant k\leqslant n$,$\left|a_i-a_k\right|+\left|a_k-a_j\right|=\left|a_i-a_j\right|$。 数据范围: - $t$ 组数据,$1\leqslant t\leqslant 1000$。 - $1\leqslant n\leqslant 10^5$。 - $1\leqslant a_i\leqslant 10^9$。 - $\sum n\leqslant 2\times 10^5$。 Translated by Eason_AC题目描述
You are given an array $ a_1, a_2, \ldots, a_n $ of positive integers. A good pair is a pair of indices $ (i, j) $ with $ 1 \leq i, j \leq n $ such that, for all $ 1 \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 $ t $ ( $ 1 \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 $ n $ ( $ 1 \leq n \leq 10^5 $ ) — the length of the array. The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1 \leq a_i \leq 10^9 $ ) where $ a_i $ is the $ i $ -th element of the array. The sum of $ n $ for all test cases is at most $ 2 \cdot 10^5 $ .
输出格式
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