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; }

												

ZOJ 3202 Second-price Auction的更多相关文章

  1. codeforces Rockethon 2015 C Second price auction [想法]

    传送门 C. Second price auction time limit per test 2 seconds memory limit per test 256 megabytes input ...

  2. RTB

    RTB —— Real Time Bidding 的简称,就是实时竞价.跟传统购买形式相比,RTB是在每一个广告展示曝光的基础上进行竞价,就是每一个PV都会进行一次展现竞价,谁出价高,谁的广告就会被这 ...

  3. Rockethon 2015

    A Game题意:A,B各自拥有两堆石子,数目分别为n1, n2,每次至少取1个,最多分别取k1,k2个, A先取,最后谁会赢. 分析:显然每次取一个是最优的,n1 > n2时,先手赢. 代码: ...

  4. 竞价拍卖理论的介绍(RTB模型中使用第二竞价模型,为的是纳什平衡,保护所有多方利益)

    英式拍卖 是最普通的拍卖方式,其形式是拍卖过程中,竞价按阶梯,从低到高,依次递增.最终由出价最高者获得拍卖物品(竞买人变成买受人). The first price auction: a form o ...

  5. 唐平中讲座笔记 Reinforcement mechanism design 20171107

    渣排版预警,纯草稿... 唐平中.研究方向是经济学和ai方向,机制设计和拍卖设计. 内容:广告优化的方法论,自动优化. [内容] Basics on mechanism design and resr ...

  6. ZOJ 1586 QS Network (最小生成树)

    QS Network Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Sta ...

  7. ZOJ 3794 Greedy Driver

    两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds       ...

  8. ural1316 Electronic Auction

    Electronic Auction Time limit: 0.5 secondMemory limit: 64 MB There is a deficit in cast-iron pigs in ...

  9. gym 101081 gym F. Auction of Services 最小生成树+倍增LCA

    F. Auction of Services time limit per test 2.0 s memory limit per test 256 MB input standard input o ...

随机推荐

  1. 【转】MFC 字体LOGFONT

    Windows的字体LOGFONT LOGFONT是Windows内部字体的逻辑结构,主要用于设置字体格式,其定义如下:typedef struct tagLOGFONTA{    LONG      ...

  2. Spring部署报错:Could not open ServletContext resource [/db.properties]

    在使用Spring MVC过程中,部署项目报错,报错信息如下: 八月 15, 2016 5:02:04 下午 org.apache.catalina.core.StandardContext list ...

  3. Linux Vi/Vim 的使用及实例

    什么是 vim? Vim是从 vi 发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用. 简单的来说, vi 是老式的字处理器,不过功能已经很齐全了,但是 ...

  4. PHP清除HTML代码、空格、回车换行符的函数

    清除HTML代码.空格.回车换行符的函数如下 function DeleteHtml($str) { $str = trim($str); $str = strip_tags($str,"& ...

  5. js使用正则表达式从url中获取参数值

    //从url中获取参数值 function getvl(name) { var reg = new RegExp("(^|\\?|&)"+ name +"=([^ ...

  6. 4 kafka集群部署及kafka生产者java客户端编程 + kafka消费者java客户端编程

    本博文的主要内容有   kafka的单机模式部署 kafka的分布式模式部署 生产者java客户端编程 消费者java客户端编程 运行kafka ,需要依赖 zookeeper,你可以使用已有的 zo ...

  7. Dll 使用 PChar 参数的小例子 - 回复 "linximf" 的问题

    本例效果图: Dll 文件: library Lib; uses   SysUtils, Classes; {$R *.res} procedure Test(p: PChar); const   T ...

  8. MySQL Server 5.7.13

    如何安装MySQL,MySQL两种安装方式_百度经验 http://jingyan.baidu.com/article/cd4c2979033a17756f6e6047.html "C:\P ...

  9. win8安装msi出现提示2503 2502的错误代码

    安装TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi时出现错误,网上查看原因是权限不够造成的 解决方法: 解决方法: 1.鼠标移到桌面左下角->右键(或者直接: ...

  10. linux系统中,tee命令的使用

    需求描述: 今天在看nginx内容的过程,遇到了tee这个命令,所以查询了下,在这里记录下使用方法. 操作过程: 1.执行以下的命令 [root@testvm ~]# uname -n | tee h ...