Memory limit:32768kb
64bit IO Format:%lld &%llu
Description
Do you know Second-price auction? It ' s very simple but famous. In a second-price auction, each potential buyer privately submits, perhaps in a sealed envelope or over a secure connectio N, his (or hers) bid for the object to the auctioneer. After receiving all the bids, the auctioneer then awards the object to the bidder with the highest bid, and charges him (O R her) The amount of the Second-highest bid.
Suppose you "re the auctioneer and you had received all the bids, you should decide the winner and the amount of money he (or she) should pay.
Input
There is multiple test cases. The first line of input contains an integer t (t <=), indicating the number of test cases. Then T test cases follow.
Each test case contains-lines:the first line of all test case contains only one integer N, indicating the number of Bidders. (2 <= N <= 100) The second line of all test case contains N integers separated by a space. The i-th integer Pi indicates the i-th bidder ' s bid. (0 < Pi <= 60000) Assume that's the highest bid is unique.
Output
For each test case, the output a line containing the integers x and y separated by a space. It indicates that the x-th bidder are the winner and the amount of money he (or she) should pay is Y.
Sample Input
2
3
3 2 1
2
6 {
Sample Output
1 2
2 4
Source
The 6th Zhejiang Provincial Collegiate Programming Contest
The AC code is as follows:
#include <iostream> #include <algorithm> using namespace std; int main () {int T;
cin>>t;
while (t--) {int n,a[101],b[101];
cin>>n;
for (int i=0;i<n;i++) {cin>>a[i];
B[i]=a[i];
} sort (b,b+n);
for (int i=0;i<n;i++) {if (a[i]==b[n-1]) cout<<i+1<< "";
} cout<<b[n-2]<<endl;
} return 0; }