你准备好了吗?
来源:互联网 发布:学做淘宝视频哪里看 编辑:程序博客网 时间:2024/05/17 02:11
Problem Description
Is this your first times participating in this kind of contest? I think most of you will answer “Yes”. So let’s do this problem as warm-up and check whether the PC^2 work properly.
Now, we will give you the information of some contests that are just like the one you are taking. Your task is to output their rank lists according to the contest rules you have already understood.
Now, we will give you the information of some contests that are just like the one you are taking. Your task is to output their rank lists according to the contest rules you have already understood.
Input
There is only one number C (<=100) in the first line of the input, which is the number of contests.
For each contest, the first line contains only one number N indicating the total number of teams. And then follow N lines. Each line has three numbers Ti, Si and Pi (1<=Ti<=N, 0<=Si<=20, 0<=Pi<=10000), which stand for the ID, Score and Penalty of the ith team of the contest respectively. Specially, all teams’ scores are distinct.
For each contest, the first line contains only one number N indicating the total number of teams. And then follow N lines. Each line has three numbers Ti, Si and Pi (1<=Ti<=N, 0<=Si<=20, 0<=Pi<=10000), which stand for the ID, Score and Penalty of the ith team of the contest respectively. Specially, all teams’ scores are distinct.
Output
For each contest, you should output the rank list (team ID) in descent order in just one line. Numbers separate exactly one space.
Sample Input
233 2 2002 1 1001 3 30021 2 2222 1 222
Sample Output
1 3 21 2
此题就是排序;先拍数据Pi,再排数据Si;都是从大到小;
# include<cstdio># include<iostream># include<algorithm>using namespace std;struct ID{ int Ti,Si,Pi;};ID id[1000];int cmp(ID n,ID m){ if(n.Pi!=m.Pi) return n.Pi>m.Pi; else return n.Si>m.Si;}int main(){ //freopen("a.txt","r",stdin); int c; cin>>c; while(c--) { int i,n,flag=1; cin>>n; for(i=0;i<n;i++) cin>>id[i].Ti>>id[i].Si>>id[i].Pi; sort(id,id+n,cmp); for(i=0;i<n;i++) { if(flag) { cout<<id[i].Ti; flag=0; } else cout<<' '<<id[i].Ti; } if(c!=0) cout<<endl; } return 0;}
0 0
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 大学毕业,你准备好了吗?
- 跳槽,你准备好了吗?
- 创新,你准备好了吗?
- WPF,你准备好了吗?
- 跳槽,你准备好了吗
- 创业,你准备好了吗?
- 跳槽,你准备好了吗
- 量产你准备好了吗
- 2013,你准备好了吗
- 跨境电商,你准备好了吗?
- RSS来了,你准备好了吗?
- RSS来了,你准备好了吗?
- 仿微信效果,主要是actionbar的一些知识
- 命令行执行python模块时提示ImportError: No module named xxx
- 最短路模板
- codeforces 449D Jzzhu and Numbers 容斥+DP
- 工作态度-勿浮躁
- 你准备好了吗?
- Linux系统编程(1)——文件与I/O之C标准I/O函数与系统调用I/O
- Jquery easyUI 自定制图标
- Ubuntu 安装phpstorm
- access-Control-Allow-Origin跨域请求安全隐患
- 数据的交换输出(2016)
- Hadoop2.2.0 NN HA详细配置+Client透明性试验【完整版】
- 物业管理中水井房水表后面的水管是属于业主的物业吗
- python核心编程(二)第六章答案(自己写,可能与标准答案有些出入)