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 4.0后,自定义Title报错 You cannot combine custom titles with other title feature
自定义Titlebar时为了避免冲突 需要修改:AndroidManifest.xml android:theme="@style/mystyle" styles.xml文件中 ...
- sql常识- UNIQUE
SQL UNIQUE 约束 UNIQUE 约束唯一标识数据库表中的每条记录. UNIQUE 和 PRIMARY KEY 约束均为列或列集合提供了唯一性的保证. PRIMARY KEY 拥有自动定义的 ...
- Cocos移植到Android-Android.mk编译文件
我们在上一篇博客中年使用的cocos工具对于C和C++源代码进行编译.事实上cocos工具读取<游戏工程目录>\proj.android\jni\目录中的Android.mk文件,进行交叉 ...
- 第二节 hibernate session介绍以及session常用方法介绍
原创地址:http://www.cnblogs.com/binyulan/p/5628579.html Session是java应用程序和hibernate框架之间的一个主要接口.它是从持久化服务中剥 ...
- Polyline转Polygon
IGeometry geo = feature.ShapeCopy; IGeometryCollection pPolyline = geo as IGeometryCollection; ISegm ...
- GDB 进行调试 使用心得
GDB 进行调试 使用心得 转 1: 对于在应用程序中加入参数进行调试的方法: 直接用 gdb app -p1 -p2 这样进行调试是不行的. 需要像以下这样使用: #gdb app ...
- TCP/IP:链路层
链路层主要目的: 1. 为IP模块发送和接收IP数据报. 2. 为ARP模块发送ARP请求和接收ARP应答. 3. 为RARP发送RARP请求和接收RARP应 ...
- ArcGIS Server10.1授权文件
3dengine,101,ecp.arcgis.server,01-jan-2020,UTE784S3EY83ZJKN0085 3dserver,101,ecp.arcgis.server,01-ja ...
- PHP中使用Luhn算法校验信用卡及借记卡卡号
Luhn算法会通过校验码对一串数字进行验证,校验码通常会被加到这串数字的末尾处,从而得到一个完整的身份识别码. 我们以数字“7992739871”为例,计算其校验位: 从校验位开始,从右往左,偶数位乘 ...
- emoji处理方法汇总
emoji资料 今天研究了emoji,挺有意思,资料挺多,摘要一些信息给大家分享,也算是自己记录学习. emoji介绍 Emoji (絵文字,词义来自日语えもじ,e-moji,moji在日语中的含义是 ...