Sichuan University Programming Contest 2011 Preliminary(for Non-SCUers) / M A Simple Problem
返回目录
题目大意: 背景是acm比赛的成绩排名规则,要求输出成绩最好的那个队。
题目类型: 排序题
题目分析: 利用 #include<algorithm> 的sort排序,自定义cmp函数。
代码:
#include<cstdio> #include<cstring> #include <algorithm> using namespace std; struct team { char name[20]; int num; int p; }; team a[102]; int cmp( const team &a, const team &b ) { if(a.num>b.num) return 1; if(a.num==b.num) { if(a.p < b.p) return 1; if(a.p == b.p) { if(strcmp(a.name, b.name) <0) return 1; } } return 0; } int main() { int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); for(int i=0; i<n; i++) scanf("%s%d%d", &a[i].name, &a[i].num, &a[i].p); sort(a, a+n, cmp); printf("%s/n", a[0].name); } }
官方标程:
利用了重载<运算符,再sort
#include<cstdio> #include<string> #include<iostream> #include<algorithm> #include<vector> #include<cstring> using namespace std; inline int Rint(){ int x; scanf("%d", &x); return x;} class tt //! { public: char str[100]; int s, p; bool operator < ( const tt & o )const { if( s != o.s )return s > o.s; if( p != o.p )return p < o.p; return strcmp(str, o.str) < 0; } }; int n; tt a[1000]; //重载了tt类型的<运算 int main() { int Tcase = Rint(); for(; Tcase -- ; printf("%s/n",a[0].str)) { n = Rint(); for( int i = 0; i < n; ++ i ) { scanf("%s", a[i].str); a[i].s = Rint(); a[i].p = Rint(); } sort(a, a + n); //! } return 0; }
转载于:https://www.cnblogs.com/tclh123/archive/2011/04/09/6171774.html
Sichuan University Programming Contest 2011 Preliminary(for Non-SCUers) / M A Simple Problem相关推荐
- Sichuan University Programming Contest 2018 Preliminary
嗯为了防止大家AK,所以这次的A题和K题我们就当做不存在好了! 经历了昨天写了两个多小时的博客没保存的心态炸裂,今天终于下了个Markdown.所以我猜这篇的格式应该会更好看一点! 好吧废话不多说 题 ...
- acm-(dp、最小树形图)Sichuan State Programming Contest 2011 I.Smart Typist
传送门 首先容易发现把字符串xxx通过替换方式变成字符串yyy会有一个代价w[x][y]w[x][y]w[x][y],这个可以利用dp来计算,如果新建字符串来产生字符串xxx,则会有个代价w[x]w[ ...
- ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest
一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点. 有t组输入 每组输入n, m, p.表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲). 然后是地图的输入.其中'@'为 ...
- Benelux Algorithm Programming Contest 2016 Preliminary 题解
A. Block Game B. Chess Tournament C. Completing the Square D. Hamming Ellipses E. Lost In The Woods ...
- 2019 The 19th Zhejiang University Programming Contest
感想: 今天三个人的状态比昨天计院校赛的状态要好很多,然而三个人都慢热体质导致签到题wa了很多发.最后虽然跟大家题数一样(6题),然而输在罚时. 只能说,水题还是刷得少,看到签到都没灵感实在不应该. ...
- Stanford Local Programming Contest 2011
这几天把SLPC2011的题目做一下 这里是题目连接:SLPC2011 A.Another Rock-Paper-Scissors Problem 题目大意:给出Sonny在每一局出石头剪刀布的规则( ...
- The 19th Zhejiang University Programming Contest Sponsored by TuSimple
Problem A Thanks, TuSimple! 比赛地址:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5 ...
- *【ZOJ - 3703】Happy Programming Contest(带优先级的01背包)
题干: In Zhejiang University Programming Contest, a team is called "couple team" if it consi ...
- 【ZOJ - 3703】Happy Programming Contest(带优先级的01背包,贪心背包)
题干: In Zhejiang University Programming Contest, a team is called "couple team" if it consi ...
最新文章
- Python --深入浅出Apriori关联分析算法(二) Apriori关联规则实战
- 【转载】快速升职加薪的10个方法
- SQL2005数据导入错误:0xc00470fe 产品级别对于..
- 简单linux蠕虫,清除Linux系统上的蠕虫程序Ramen
- Vue子组件与父组件之间的通信
- jquery-动效方法-animate
- AndroidStudio安卓原生开发_UI控件_TextView_Button_EditText---Android原生开发工作笔记97
- Storm入门(七)可靠性机制代码示例
- 荷兰研制出世界最小U盘:长度不到2厘米
- eclipse无法运行PHP_eclipse 无法运行php文件怎么办
- html编写qq整人代码,vbs代码大全?vbs整人代码?qq代码大全?常用VBS代码 值得一看
- 2021全国电赛H题回顾
- Oracle错误——user ** lacks CREATE SESSION privilege logon denied
- libtorch显存管理示例
- 金融中需要的计算机知识,金融笔试中的综合知识一般会考什么?
- 2022-08-08 第二小组 张明旭 Java学习记录
- 小学四则运算练习软件需求说明
- 微信点餐系统——买家类目service层创建并测试通过
- 阿朵洒洒的撒多撒多撒啊
- 用AR试妆打通美妆新零售,岂止台湾“玩美彩妆”一家?