Large but not largest

1

1 votes
Easy
Problem

You are given an array A. Your task is to find out the largest and second largest elements of A. If there is no second largest element then print -1 in place of second largest element.

 

INPUT FORMAT:

Line 1 will contain an integer T that denotes the number of test cases.

Next T lines will contain an array of intergers. In which, first integer denotes N , the size of an array followed by N integers.

 

OUTPUT FORMAT:

T lines of output with  two integers on each line

 

Constraints

1 <= T <= 100

1 <= N <= 106

0 <= A[i] <= 109

 

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?