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 ...
随机推荐
- android代码设置、打开WLAN wifi热点及热点的连接
其实创建热点很简单,先获取到wifi的服务,再配置热点名称.密码等等,然后再通过反射打开它就OK了. 下面我们看看创建热点的代码实现: 这一段是开启WLAN热点,并可以指定好它的热点名和密码 支行后, ...
- JavaScript之模拟评星打分
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312&qu ...
- Linux msgsnd : invalid argument
msgsnd(message id, buffer, sizeof buffer, ...); Important: buffer[0]不能为0!!!
- C#——字符操作
题目要求:用户随机输入字母及数字组成的字符串,当用户连续输入字符串‘hello’时,程序结束用户输入,并分别显示用户输入的字母及数字的数目. 代码: using System; using Syste ...
- IOS 如何选择delegate、notification、KVO?(转)
前面分别讲了delegate.notification和KVO的实现原理,以及实际使用步骤,我们心中不禁有个疑问,他们的功能比较类似,那么在实际的编程中,如何选择这些方式呢? 在网上看到一个博客上详细 ...
- css笔记——小图标文字对齐中级解决方案
出处:http://www.zhangxinxu.com/study/201603/icon-text-vertical-align.html css .icon { display: inline- ...
- md5值计算
1.md5(Message Digest 5th/消息概要加密算法 第5版) REFER: MD5 On wikipedia 2.应用范围 ① 验证下载文件的完整性 ② 3.关于MD5的几个问题 ①只 ...
- Swing组件Jtree,JTablePane选项卡运用
今天开始写技术博客,说实话,本没有什么技术,说是总结也好,说是分享也罢,总之是想自己有意识的做一些事情,作为一名即将毕业的大学生,总是想以最好的状态,去面向社会,今天就是我准备好了的时候,本人将技术博 ...
- C#,PHP对应加密函数
require_once "JunDes.php"; $jDes=new JunDes(); echo $jDes->encode('98765'); //echo $jDe ...
- 页面有什么隐藏bug:字体,图片
字体: 一行(太长)-display:inline-block,text-overflow: ellipsis;max-width:xxpx 多行(太高,太矮)-设置max-height,min-he ...