CF386A.Second-Price Auction

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

本题中,我们考虑一种特殊的拍卖方式,称为第二价格拍卖(second-price auction)。与普通拍卖类似,共有 nn 位竞拍者,每位竞拍者提交一个出价(即其愿意支付的价格)。该拍卖为密封式拍卖(closed auction),即每位竞拍者秘密地向拍卖组织者告知自己愿意支付的价格。随后,出价最高的竞拍者成为获胜者。然而,获胜者所实际支付的价格并非其自己的出价,而是其余所有竞拍者所报出的最高出价(因此得名“第二价格拍卖”)。

请编写一个程序,读入各位竞拍者的出价,并确定获胜者及其实际需支付的价格。假设所有出价互不相同。

输入格式

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.

输入的第一行包含一个整数 nn(2≤n≤10002 \leq n \leq 1000),表示竞标者人数。第二行包含 nn 个互不相同的整数 p1,p2,…,pnp_1, p_2, \dots, p_n,以单个空格分隔(1≤pi≤100001 \leq p_i \leq 10000),其中 pip_i 表示第 ii 位竞标者所报的价格。

输出格式

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

单行输出应包含两个整数:获胜者的索引及其将支付的价格。索引为 1 起始。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页