ZOJ 3202 Second-price Auction (模拟)
来源:互联网 发布:知乎 飞利浦电动剃须刀 编辑:程序博客网 时间:2024/09/21 11:15
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
233 2 124 9
Sample Output
1 22 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
- ZOJ 3202 Second-price Auction (模拟)
- zoj 3202 Second-price Auction
- ZOJ 3202 Second-price Auction
- zoj 3202 Second-price Auction
- ZOJ#3202:Second-price Auction
- ZOJ 3202 Second-price Auction
- ZOJ 3202 Second-price Auction
- ZOJ 3202Second-price Auction(排序)
- ZOJ-3202-Second-price Auction【6th浙江省赛】
- Second-price Auction
- Second-price Auction
- Codeforces386A. Second-Price Auction
- codeforces Second-Price Auction
- Second-price Auction
- zoj3202 Second-price Auction
- ZOJ3202-Second-price Auction
- A. Second-price Auction
- Codeforces 513C Second price auction (bruteforce)
- 39-textarea自动截取控制输入的长度
- 堆中插入元素
- (step7.2.1)hdu 1395(2^x mod n = 1——简单数论)
- GPT转MBR分区格式图文教程
- C# 窗口隐形 不影响控件功能
- ZOJ 3202 Second-price Auction (模拟)
- [poj 3468]A Simple Problem with Interger[线段树][区间更新]
- C#属性总结
- flash 无刷新上传文件 图片缩略图 后台
- uva 1319 Maximum(贪心)
- 学习中的一些笔记,保留起来备用
- 等概率随机函数的实现
- ajax 小小封装
- 编程与生活