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; }
ZOJ 3202 Second-price Auction的更多相关文章
- codeforces Rockethon 2015 C Second price auction [想法]
传送门 C. Second price auction time limit per test 2 seconds memory limit per test 256 megabytes input ...
- RTB
RTB —— Real Time Bidding 的简称,就是实时竞价.跟传统购买形式相比,RTB是在每一个广告展示曝光的基础上进行竞价,就是每一个PV都会进行一次展现竞价,谁出价高,谁的广告就会被这 ...
- Rockethon 2015
A Game题意:A,B各自拥有两堆石子,数目分别为n1, n2,每次至少取1个,最多分别取k1,k2个, A先取,最后谁会赢. 分析:显然每次取一个是最优的,n1 > n2时,先手赢. 代码: ...
- 竞价拍卖理论的介绍(RTB模型中使用第二竞价模型,为的是纳什平衡,保护所有多方利益)
英式拍卖 是最普通的拍卖方式,其形式是拍卖过程中,竞价按阶梯,从低到高,依次递增.最终由出价最高者获得拍卖物品(竞买人变成买受人). The first price auction: a form o ...
- 唐平中讲座笔记 Reinforcement mechanism design 20171107
渣排版预警,纯草稿... 唐平中.研究方向是经济学和ai方向,机制设计和拍卖设计. 内容:广告优化的方法论,自动优化. [内容] Basics on mechanism design and resr ...
- ZOJ 1586 QS Network (最小生成树)
QS Network Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit Sta ...
- ZOJ 3794 Greedy Driver
两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds ...
- ural1316 Electronic Auction
Electronic Auction Time limit: 0.5 secondMemory limit: 64 MB There is a deficit in cast-iron pigs in ...
- 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 ...
随机推荐
- python json.dumps 中文字符乱码
场景:微信公众号推送消息,中文乱码. Date:2017-05-11 10:58:40.033000,\u4f60\u597d 解决方法: python dumps默认使用的ascii编码 ...
- (转)SCR, PCR, ESCR, PTS, DTS
1. SCR SCR是存在于PS中的,即PS的pack里面的一个field.他用来指定这个PS的pack期望的到达decoder的时间. 2. ESCR ESCR是位于PES里 ...
- erlang -- ios apns provider -- erlang 实现
os apns-apple notification server 与第三方provider的通信原理网上已有很多介绍,这里不再介绍,有想了解的大家可以去IOS官网https://developer. ...
- bootstrap+PHP表单验证
来源:http://www.sucaihuo.com/php/1814.html demo http://www.sucaihuo.com/jquery/18/1814/demo/
- C语言对文件的操作函数用法详解1
在ANSIC中,对文件的操作分为两种方式,即: 流式文件操作 I/O文件操作 一.流式文件操作 这种方式的文件操作有一个重要的结构FILE,FILE在stdio.h中定义如下: typedef str ...
- 使用mshflxgd.ocx控件
msflxgrd.ocx - Microsoft FlexGrid Control 原先使用的是msflxgrd控件,但是使用过程中发现,Cell中的中文字符串在英文系统下显示“??”,查找资料发现该 ...
- Sass基础——Rem与Px的转换
rem是CSS3中新增加的一个单位值,他和em单位一样,都是一个相对单位.不同的是em是相对于元素的父元素的font-size进行计算:rem是相对于根元素html的font-size进行计算.这样一 ...
- Scala 读文件
环境: Cent OS 6.3 以下说明怎样读取一个文件. 代码: $ cat fileRead.scala import scala.io.Source if (args.length > 0 ...
- ios 6以后,UILabel全属性
一.初始化 1 UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 40, 120, 44)]; 2 3 [s ...
- list中的比较
一说到list的的确不知道写些什么.....我觉得别人总结的比我写的还要好很多. 我擅长记录自己的误区. |--List:元素是有序的(怎么存的就怎么取出来,顺序不会乱),元素可以重复(角标1上有个3 ...