In this problem we consider a special type of an auction, which is called the Second-price auction. As in regular auction n bidders place a bid which was price a bidder ready to pay. The auction is closed, and that's, each bidder secretly informs the organizer of the auction price he's willing to pay. After that, the auction winner are the participant who offered the highest price. However, he pay isn't the price he offers, but the highest price among the offers of other participants (hence the name:the Second-price auction).
Write A program This reads prices offered by bidders and finds the winner and the price he'll pay. Consider that all of the offered prices is different. Input
The first line of the input contains N (2≤n≤1000)-number of bidders. The second line contains n distinct integer numbers p1, p2, ... pn, separated by single spaces (1≤pi≤10000), where pi Stands for the price offered by the i-th bidder. Output
The single output line should contain, Integers:index of the winner and the price he'll pay. Indices is 1-based. Examples Input
2
5 7
Output
2 5
Input
3
10 2 8
Output
1 8
Input
6
3 8 2 9 4 14
Output
6 9
AC:
#include <stdio.h> #include <string.h>
#include <algorithm>
using namespace std;
Int main ()
{
int n,i,m,j;
Int a[1005];
scanf ("%d", &n);
J=0;m=0;
for (i=0;i<n;i++)
{
scanf ("%d", &a[i]);
if (M<a[i])
{
M=a[i];
J=i;
}
}
Sort (a,a+n);
printf ("%d%d\n", ++j,a[n-2]);
return 0;
}