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 ...
随机推荐
- Xenocode Postbuild 2010 for .NET 混淆工具的详细使用步骤【转】
1,首先我们需要去下载这个工具去,我这里倒是有一个下载的网址,已经被破解了,而且有序列号 http://download.csdn.net/tag/Xenocode+Postbuild+2010+fo ...
- Xshell和SecureCRT等SSH下使用Tmux及Byobu(解决Byobu被statusline信息面板刷屏问题)
Vim的vsplit用得爽吧!多命令行模式,同样让你爽得不蛋疼! 下面介绍一下两个终端多控制台软件:Tmux 和 Byobu!本文还是以Xshell为主进行介绍! --------------Tmux ...
- linux -- gedit快捷键
Shortcuts for tabs:Ctrl + Alt + PageDown Switches to the next tab to the left.Ctrl + Alt + PageD ...
- sqlldr导入数据(以PostgreSql>>>Oracle为例)
1.在目标数据库中创建表 1.1点击源表,复制创建语句 1.2 修改数据类型以匹配目标数据库,如: 字符串类型:character varying(20)>>>varchar2(20 ...
- 【转】Internet与Intranet区别
提起Internet,大家都知道它是一个蓬勃发展的国际互联网. 而Intranet则是近两年才发展起来的新事物,通常被称作企业内部网. Internet是一组全球范围内信息资源的名字.这些资源非常巨大 ...
- easyui_datagrid合并行单击某行选中所有
实现如下功能: 代码: <table id="dg" class="easyui-datagrid" title="Merge Cells fo ...
- java.util.logging.Logger使用具体解释
java.util.logging.Logger不是什么新奇东西了,1.4就有了,但是由于log4j的存在,这个logger一直沉默着,事实上在一些測试性的代码中,jdk自带的logger比log4j ...
- Android package属性、package name和Application ID三者的联系及区别
package属性:在AndroidManifest.xml文件中. package name:模块结构的包名. Application ID:模块defaultConfig块下的applicatio ...
- 子Fragment获取父Fragment
在子Fragment操作父Fragment的思路 ((FragmentRecyclerBD)FragmentAppointmentBD.this.getParentFragment()).change ...
- Android中开发习惯
我觉得首先是命名规范.命名规范这种东西每个人都有自己的风格,Google 也有自己的一套规范(多看看 Android 系统源码就明白了).好的规范可以有效地提高代码的可读性,对于将来接手代码的小伙伴也 ...