#K68587. Max Swapped Pair

    ID: 32897 Type: Default 1000ms 256MiB

Max Swapped Pair

Max Swapped Pair

You are given an array of integers. Your task is to find two indices \(i\) and \(j\) (with \(i < j\)) such that the sum of the corresponding elements is maximized. In the event that there are multiple pairs with the same maximum sum, choose the pair with the smallest \(i\), and if there is still a tie, choose the pair with the smallest \(j\). If the array contains fewer than two elements, output "None".

Note: After finding the two indices, print them in increasing order. That is, if the indices obtained are \(a\) and \(b\), output \(\min(a, b)\) followed by \(\max(a, b)\).

inputFormat

The input is given via standard input and consists of two lines:

  • The first line contains a single integer \(n\) — the number of elements in the array.
  • The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

If there exist at least two elements in the array, output two integers separated by a space representing the indices of the two numbers that form the maximum possible sum. The indices must be printed in increasing order. If the array contains fewer than two elements, output "None".

## sample
5
5 1 3 7 9
3 4

</p>