# ZOJ 3202 Second-price Auction

Second-price Auction

Time Limit: 1 Second      Memory Limit: 32768 KB

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 connection, his (or her) 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 (or her) the amount of the second-highest bid.

Suppose you're the auctioneer and you have received all the bids, you should decide the winner and the amount of money he (or she) should pay.

Input

There are multiple test cases. The first line of input contains an integer T(T <= 100), indicating the number of test cases. Then T test cases follow.

Each test case contains two lines: The first line of each test case contains only one integer N, indicating the number of bidders. (2 <= N <= 100) The second line of each test case contains N integers separated by a space. The i-th integer Pi indicates the i-th bidder's bid. (0 < Pi <= 60000) You may assume that the highest bid is unique.

Output

For each test case, output a line containing two integers x and y separated by a space. It indicates that the x-th bidder is the winner and the amount of money he (or she) should pay is y.

Sample Input

```2
3
3 2 1
2
4 9```

Sample Output

```1 2
2 4```
```#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>

using namespace std;
int n;
struct Node
{
int tag;
int value;
}a[105];
int cmp(Node a,Node b)
{
return a.value>b.value;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i].value);
a[i].tag=i;
}
sort(a+1,a+n+1,cmp);
printf("%d %d\n",a[1].tag,a[2].value);

}
return 0;

}```

0 条评论

• ### HOJ-2056 Bookshelf（线性动态规划）

L is a rather sluttish guy. He almost never clean up his surroundings or regulat...

• ### POJ-1953 World Cup Noise（线性动规）

World Cup Noise Time Limit: 1000MS Memory Limit: 30000K Total Submissio...

• ### CodeForces 665B Shopping

B. Shopping time limit per test 1 second memory limit per test 256 megabyt...

• ### Web前端学习（打卡机）

在补齐了Java后端的短板之后，我准备补补前端的课。这篇文章可以作为我前端学习的过程记录（打开机）。

• ### HDUOJ-------2493Timer(数学 2008北京现场赛H题)

Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav...

• ### 什么是SAP物料主数据里的Batch

Materials are produced and theoretically have the same properties. Nevertheless ...

• ### 如何启用SAP Business by design里的Correction Invoice功能

Subject: [Tip] How to enable the function Correction Invoice for customer invoic...

• ### Code forces 719A Vitya in the Countryside

A. Vitya in the Countryside time limit per test:1 second memory limit per test:2...

• ### 循环热管的动态状态空间建模与基于模型的控制设计(CS SY)

对于航空航天、汽车或服务器系统中电子元件的热控制，散热器通常远离热源。因此，热传导系统是有效冷却电子元件所必需的。循环热管(LHPs)就是这样的传热系统，它利用...

• ### 有限闭包系统中的极大闭集和半空间分离(CS AI)

研究了抽象闭包系统中闭集和半空间分离的一些算法性质。假设基础闭包系统是有限的，并由相应的闭包算子给出，证明了半空间分离问题是np完全的。与此相反，对于极大闭集分...