302032: CF386A. Second-Price Auction

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Second-Price Auction

题意翻译

给你n个数,求出其中最大值的编号和第二大的值。 输入: 第一行,输入一个数n; 接下来输入n个整数。 输出: 输出其中最大值的编号和第二大的值,中间用空格隔开 感谢@zhangyanbo♐ 提供的翻译

题目描述

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 is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the auction winner is the participant who offered the highest price. However, he pay not the price he offers, but the highest price among the offers of other participants (hence the name: the second-price auction). Write a program that reads prices offered by bidders and finds the winner and the price he will pay. Consider that all of the offered prices are different.

输入输出格式

输入格式


The first line of the input contains $ n $ ( $ 2<=n<=1000 $ ) — number of bidders. The second line contains $ n $ distinct integer numbers $ p_{1},p_{2},...\ p_{n} $ , separated by single spaces ( $ 1<=p_{i}<=10000 $ ), where $ p_{i} $ stands for the price offered by the $ i $ -th bidder.

输出格式


The single output line should contain two integers: index of the winner and the price he will pay. Indices are 1-based.

输入输出样例

输入样例 #1

2
5 7

输出样例 #1

2 5

输入样例 #2

3
10 2 8

输出样例 #2

1 8

输入样例 #3

6
3 8 2 9 4 14

输出样例 #3

6 9

Input

题意翻译

给你n个数,求出其中最大值的编号和第二大的值。 输入: 第一行,输入一个数n; 接下来输入n个整数。 输出: 输出其中最大值的编号和第二大的值,中间用空格隔开 感谢@zhangyanbo♐ 提供的翻译

加入题单

上一题 下一题 算法标签: