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. imx6 android4.2 编译

    编译imx6dl android4.2的镜像,记录编译的命令. Build Android Image # Build Android images for i.MX6 SABRE-SD boards ...

  2. vector 排序

    #include <vector> #include <algorithm> 一.vector保存的是基础数据类型(int.char.float等) vector<int ...

  3. C# 过滤sql特殊字符方法集合

    1./// <summary>    /// 过滤不安全的字符串    /// </summary>    /// <param name="Str" ...

  4. PS流的格式和解析总结

    对于PS流,最近因为工作需要,所以MPEG2中的PS流格式和解包过程进行了学习. 首先我们需要知道PS包流格式是怎么样的: (来自http://blog.csdn.net/chen495810242/ ...

  5. CentOS 7 Minimal编译安装MySQL5.6

    写在前面,编译安装MySQL的优势:平台无关.可设定参数按需安装.安装的MySQL目录独立(方便清楚).更好的平台耦合及运行性能(很多运维的观点):缺点:编译安装较慢. 一.撤换系统防火墙 注:Cen ...

  6. python3.4连接mysql

    参考:http://www.blogjava.net/huyi2006/articles/247966.html 开发环境:win7_x64 + python3.4.3 + mysql5.6.23 准 ...

  7. iOS 使用AFNetworking 设置cookie

    本问题是由于多账号访问统一服务器时, 由于服务器那边接收到sessionid一样, 故无法区分账号信息. 所以需要在移动端请求的时候重新设置cookie, 步骤如下: 1. 在登录的时候, 先将 re ...

  8. date详解

    在linux环境中,不管是编程还是其他维护,时间是必不可少的,也经常会用到时间的运算,熟练运用date命令来表示自己想要表示的时间,肯定可以给自己的工作带来诸多方便. 1.命令格式: date [参数 ...

  9. oracle 死锁和锁等待的区别

    所谓的锁等待:就是一个事务a对一个数据表进行ddl或是dml操作时,系统就会对该表加上表级的排它锁,此时其他的事务对该表进行操作的时候会等待a提交或是回滚后,才可以继续b的操作 所谓的死锁:当两个或多 ...

  10. Java几款性能分析工具的对比

    在给客户的应用程序维护的过程中,我注意到在高负载下的一些性能问题.理论上,增加对应用程序的负载会使性能等比率的下降.然而,我认为性能下降的比率远远高于负载的增加.我也发现,性能可以通过改变应用程序的逻 ...