The 6th Zhejiang Provincial Collegiate Programming Contest->ProblemA:Second-price Auction
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3202
题意:拍卖东西,以第二高价的价格卖给出第一高价的人。输出最后获得东西的人的序号和要出的价钱。
思路:(最笨的方法)用结构体来排序。
#include<bits/stdc++.h>
using namespace std;
struct hzx {
int id;
int a;
};
int comp1(const void *p,const void *q) {
return ((struct hzx *)p)->a-((struct hzx *)q)->a;
}
int main() {
int t,n;
struct hzx aa[];
cin>>t;
while(t--) {
cin>>n;
for(int i=; i<n; i++) {
cin>>aa[i].a;
aa[i].id=i;
}
qsort(aa,n,sizeof(struct hzx),comp1);
printf("%d %d\n",aa[n-].id+,aa[n-].a); }
return ;
}
The 6th Zhejiang Provincial Collegiate Programming Contest->ProblemA:Second-price Auction的更多相关文章
- The 6th Zhejiang Provincial Collegiate Programming Contest->Problem I:A Stack or A Queue?
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3210 题意:给出stack和queue的定义,一个是先进后出(FILO), ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504 The 12th Zhejiang Provincial ...
- zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)
Floor Function Time Limit: 10 Seconds Memory Limit: 65536 KB a, b, c and d are all positive int ...
随机推荐
- 编译mosquitto出现的问题
[root@localhost mosquitto-1.3]# make WITH_TLS=no set -e; for d in lib client src; do make -C ${d}; d ...
- 【Cocos2d入门教程五】Cocos2d-x动作篇
动作类(Action)是所有动作的基类,它创建的一个对象代表一个动作.动作作用于Node,包括继承于之下的Layer.Sprite.因此每个动作 都需要由Node对象或者其继承者执行.动作类(Acti ...
- sql常识-Join
SQL join 用于根据两个或多个表中的列之间的关系,从这些表中查询数据. Join 和 Key 有时为了得到完整的结果,我们需要从两个或更多的表中获取结果.我们就需要执行 join. 数据库中的表 ...
- base.AutoScaleMode = AutoScaleMode.Font; 方法“InitializeComponent”内的代码由设计器生成,不应手动修改。请移除任何更改,然后尝试重新打开设计器”。
http://www.taohuiduo.com 反编译后的工程文件用VS2010打开后,在打开窗体时会出现一系列错误提示: 第一种情况: “设计器无法处理第 152 行的代码: base.AutoS ...
- 利用ADO方式连接SQLServer2008出现的问题
在利用ADO方式连接SQLServer2008的过程中遇到了很多问题,在网上也没有找到许多有利的信息,花了两天时间,终于把所有问题都搞定了.在这里和大家分享一下经验,希望后来者能少走弯路. 很多教程说 ...
- C#程序员整理的Unity 3D笔记(十五):Unity 3D UI控件至尊–NGUI
目前,UGUI问世不过半年(其随着Unity 4.6发布问世),而市面上商用的产品,UI控件的至尊为NGUI:影响力和广度(可搜索公司招聘Unity 3D,常常能看到对NGUI关键词). NGUI虽然 ...
- 韩顺平细说Servlet视频系列意外收获之用命令行编译带有包的java类解决方案
命令行编译带有包的java类 在命令行编译这一块,基本上都是新手入门时了解一下,然后就直奔IDE而去.这样固然没错,就怕那些--.然后今天在视频中看到了这种方法,觉得可能会用到,所以就记录下来了,以备 ...
- linux 截取时间段的日志
sed -n '/14:[0-9][0-9]:[0-9][0-9]/p’ haproxy.log 截取14点的日志 cat haproxy.log-20160302 | grep xslh ...
- RestFul && HATEOAS && Spring-Data-Rest介绍
1.什么是RestFul 经常上网的同学会发现,现代软件的一个重要趋势就是互联网化,几乎没有一款软件是纯粹的单机版了.通常的情况下,软件管理着服务器的资源以及这些资源的状态变化,用户通过在浏览器输入h ...
- Repeater中将int类型和bool类型的字段以字符显示出来
图一 图二 比如将图一中是否显示中的列显示以图二中的方式显示: 方法1: 1.在后台编写方法:a.aspx.cs代码如下 //IsShow字段显示的方法public string GetStrIsSh ...