ZOJ 3202 Second-price Auction (模拟)

Codeforces 513C Second price auction (bruteforce) 问题描述: 如题所说,second price auction,讲的是几个人拍卖,出价最高的人以第二名的价格购得产品。给定的数据是第i个人出价的上下界,每种钱都是等可能性的,求最后花费钱的期望。 其实曾经做过这类的游戏所以规则还是一眼即明,问题就在于题目到底该怎么做。 对于每一个可能出现的价钱,枚举一种组合情况(意为对于每一个人,枚举其出的钱是大于等于该价钱,还是小于该价钱),这种时间复杂度 阅读详情

Second-price Auction
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3202

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

water.


完整代码:

/*30ms,0KB*/

#include<cstdio>

int main(void)
{
	int t, n;
	int i, j;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		int p1 = -1, p2 = -1, x;
		for (i = 1; i <= n; i++)
		{
			scanf("%d", &j);
			if (j > p1)
				p2 = p1, p1 = j, x = i;
			else if (j > p2)
				p2 = j;
		}
		printf("%d %d\n", x, p2);
	}
}

Source: The 6th Zhejiang Provincial Collegiate Programming Contest


工程伦理ppt 工程伦理学 第一章 工程与伦理 1.1 如何理解工程 一、技术与工程的区别 二、技术与工程的联系 三、工程的定义 五、工程具有不确定性和探索性 六、理解工程活动的7个维度 1.2 如何理解伦理 一、道德与伦理 二、不同的伦理立场 三、伦理困境与伦理选择 1.3 工程实践中的伦理问题 一、工程活动中的行动者网络(具有动态性和网络性) 二、主要的工程伦理问题 三、工程伦理问题的特点 1.4 如何处理工程实践中的伦理问题 一、工程实践中伦理问题的辨识 二、处理工程伦理问题的基本原则 三、应对工程伦理问题的基本思路 阅读详情

相关推荐

LTC3783 LED驱动控制器设计与效率优化详解

开关电源控制器是现代LED照明的核心器件,通过电流模式控制实现高效能量转换。其核心原理是通过采样电阻检测负载电流,配合误差放大器形成闭环调节,在汽车电子、显示背光等场景中确保±3%的电流精度。LTC3783作为典型代表,集成升压/降压-升压多拓扑支持,配合PWM调光技术可实现3000:1的无色偏调光范围。在工程实践中,需重点考量功率电感选型、MOSFET开关损耗与热管理设计,例如在38W功率方案中采用10μH/5A电感和4.5mΩ MOSFET可达成95%效率。该方案特别适用于需要应对9-36V宽输入电压波

weixin_36231030的博客 399

2014ACM集训13级PK赛4-Second-price Auction

Description 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 connectio

顺便A道题 957

Ubuntu 24.04 部署 EMQX 5.8 开源版MQTT服务器:从零搭建到实战应用

本文详细指导如何在Ubuntu 24.04系统上部署EMQX 5.8开源版MQTT服务器。内容涵盖从环境准备、安装Erlang、下载安装包到启动服务的完整步骤,并提供了验证服务、配置网络防火墙以及通过WebSocket工具进行基础消息收发的实战方法,帮助用户快速搭建稳定、免费的物联网消息中间件。

weixin_29209825的博客 293

ZOJ 3202 Second-price Auction (A)

Second-price AuctionTime Limit: 1 Second Memory Limit: 32768 KBDo you know second-price auction? It's very simple but famous. In a second-price auction, each potential buyer privately submits, pe...

weixin_30535843的博客 285

海康VisionMaster与西门子PLC1200进行S7通信

通信是连通算法平台和外部设备的重要渠道,在海康VisionMaster算法平台中既支持外部数据的读入也支持数据的写出,当通信构建起来以后既可以把软件处理结果发送给外界,又可以通过外界发送字符来触发相机拍照或者软件运行。 本文以西门子PLC1200作为外部设备为例,讲解海康VisionMaster与西门子PLC1200进行S7通信。......

haier123888的博客 1万+

免杀思路总结

免杀思路总结 1.免杀技术简介 1.免杀的重要性 2.免杀的难度 3.杀毒软件的排行 国外 国内 1 、Bitdefender 1、360 2 、Norton 360 2、智量安全(没测过,据说很厉害) 3 、Kaspersky 3、火绒安全 4 、Webroot 4、金山独霸 5 、Trend Micro 5

LiBai'S BLOG 1万+

A second-price auction

如果A出价低于800元,可能会导致其失去以合理价格赢得拍卖的机会,如在B出价700元,C出价500元的情况下,A若出价低于700元就会失去赢得拍卖的机会,而按800元出价就能赢得拍卖且获得100元收益;如果A出价高于800元,虽然可能赢得拍卖,但支付价格可能会高于其真实估价,从而降低或失去收益,如A出价900元,在其他情况不变时,虽然能赢得拍卖,但收益变为800 - 700 = 100元,与出价800元时相同,若第二高的出价高于800元,A的收益就会变为负。同理,B和C按照自己的真实估价出价也是最优的。

杨善锦技术专栏 942

PCIE总线及其PCIE SWITCH的使用

PCIe总线与PCI最大的区别在工作原理上,PCIe是采用点到点的串行方式进行传输的,被称为“串行PCI”,由于采用了串行方式传输使得其工作频率可以达到2.5Ghz,大大增加了传输速率,同时采用全双工的通信方式,使得其传输速度提高了一倍,每一个PCIe总线设备与外部通信时有四根数据总线,分别有两个RX和TX,两根用于发送,两根由于接收。PCIe switch中文翻译为PCIe开关或PCIe交换机,主要作用将PCIe设备互联,PCIe switch芯片与其设备的通信协议都是PCIe;

zxm8513优快云博客 4735

Second-price Auction

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 ...

Y_yunhu的博客 1154

13.0 针对跳转不存在Activity崩溃处理,改成弹Toast提示,去掉崩溃弹窗,避免app崩溃退出

在开发过程中,在app跳转到某个没注册的Acitivity时,往往会出现崩溃的场景,这样也不好,接下来就从framework中来拦截这个崩溃,改成toast提示,

安卓兼职framework和app工程师的博客 48

散户渡劫指南:从炼气期到化神期的量化之路

经常有人问我普通人怎么学习量化交易,我就在想怎么学了量化就不是普通人了吗,可能他的意思是类比修仙,量化素人如何修炼进阶,今天就将量化学习每个阶段均对标修仙境界的核心能力与心法要诀一一介绍,助你从“交易凡人”蜕变为“量化金仙”。

木头大左的博客 1338

zoj 3202 Second-price Auction

zoj 3202  Second-price Auction        题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3365 模拟水 backgrond konwledge: 2008-08-01 15:08 对于拍卖市场,我们通常想到的是,谁出价高交易物即给谁。可是,你是否想到:拍卖人可能说“

slicer的技术交流栈 1012

69页完整版智慧港口综合解决方案

智慧港口需求4港机远程操控等自动化改造需求自动化码头AGV无线通信及专用视频系统需求安全生产视频监控类需求港机RCMS及设备管理需求岸边智能理货码头三维全景应用智慧港口解决方案5自动化码头AGV/跨运车/无人集卡无线接入港机远控视觉及冗余无线通信视觉集卡防吊起系统集装箱码头岸边智能理货港机RCMS系统无线接入港机智能化管理(无线高清视频监控、一键报警、远程抄表系统)港口拖轮无线接入岸边溢油监测系统TD-LTE覆盖及业务终端接入港口生产管理系统港口可视化集群调度港口GiNMS综合网络设备智能管理全球作业效率最

zuoan1993的博客 2129

zoj 3202

//3202 optimize 不使用数组,找出最大和次大的数,并记录最大数的位置#include using namespace std;int main(){ int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); int max1=-1; int max2; sca

Solidfish的专栏 1084

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

A. Second-price Auction

A. Second-price Auction Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: %lld      Java class name: Main Submit Status Font PID: 18109 Do you know second-price

NITjianbagengmu的博客 569

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

codeforces Second-Price Auction

题目链接:http://codeforces.com/problemset/problem/386/A 题目意思:简单,就是有n个人投标某个东西,有n个数,找出最大的数的下标和第二大数就好了!就是这么简单。 #include #include using namespace std; int A[1001]; int main(void) { int

笨小孩的专栏 1119

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

题解CF386A【Second-Price Auction】

此题的感想:此题难度为提高+/省选-,描述又如此简单,我顿时傻眼了,于是我就去看了看数据范围:2&lt;=n&lt;=1000,顿时感觉自己又A了道水题,事后才发现这题如此毒瘤 我一开始的思路: ①:存储思想: 开三个变量,maxn,maxb,secondmaxn,maxb,secondmaxn,maxb,second。其中maxnmaxnmaxn表示当前范围内的最大值,maxbm...

xxyyztg的博客 304

【打CF,学算法——三星级】CodeForces 513C Second price auction (进制状态表示)

题目链接:CF 513C 题面: C. Second price auction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Nowadays, mo

David_Jett 1183

CodeForces - 386A Second-Price Auction

In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is clo...

林伊的博客 499

ZOJ 3202 Second-price Auction

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)

Occult 439

ZOJ 3202

题意找出数组中最大值的下标(注意是从1开始的),和第二大值功能关于找最大值下标用类似选择排序即可 关于第二大值要通过排序,然后倒数第二个即为所求值AC代码// POJ3202 #include <iostream> #include <algorithm> using namespace std; int main(){ int n; cin>>n; while(n--){

阳光心态,健康人生的博客 739

zoj3202 Second-price Auction

Second-price Auction Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Status Description Do you know second-price auction? It's very simpl

acm_1361677193的专栏 468

省赛热身赛第三场——Second-price Auction

原题: Description 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 ...

weixin_33700350的博客 152

ZOJ-3202

#include int main() { int n; scanf("%d", &n); while (n--) { int total, max, next, num, index, i; scanf("%d", &total); scanf("%d", &max); scanf("%d", &next); num = max + next; max = ma

xhldtc的专栏 595

ZOJ-3202 最大值和次大值

3202:一群人竞拍。最高价者获胜,只需付第二高的价格。输出获胜者序号和须付价格。 Sample Input 2 3 3 2 1 2 4 9 Sample Output 1 2 2 4 [code="c++"] #include using namespace std; int main() { int casen; in...

linest 226

Codeforces386A. Second-Price Auction

A. Second-Price Auction time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In this problem we consider a specia

jjaw2013 941
上一篇: Codeforces Round #147 (Div. 2) / 237A Free Cash (模拟)
下一篇: UVa 11292 / POJ 3646 / HDU 1902 Dragon of Loowater (贪心)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值