你准备好了吗?
来源:互联网 发布:淘宝的订单系统架构 编辑:程序博客网 时间:2024/04/27 20:09
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
Author
代码:
#include<stdio.h>#include<malloc.h>#include<algorithm>#include<iostream>using namespace std;struct pc{ int a;// 编号 int b;// 总和 }*x;bool mcp(pc b1,pc b2){ return b1.b>b2.b;}int main(){ int n,t,i,c1,c2; scanf("%d",&t); while(t--) { scanf("%d",&n); x=(pc *)malloc(sizeof(pc)*n);// 动态开辟一个数结构体数组x[n] for(i=0;i<n;i++) { scanf("%d%d%d",&x[i].a,&c1,&c2); x[i].b=c1+c2; } sort(x,x+n,mcp);// 调用系统排序函数 从大到小排序 for(i=0;i<n;i++) if(i==0)printf("%d",x[i].a); else printf(" %d",x[i].a); if(t!=0)printf("\n"); } return 0;}
0 0
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 你准备好了吗?
- 大学毕业,你准备好了吗?
- 跳槽,你准备好了吗?
- 创新,你准备好了吗?
- WPF,你准备好了吗?
- 跳槽,你准备好了吗
- 创业,你准备好了吗?
- 跳槽,你准备好了吗
- 量产你准备好了吗
- 2013,你准备好了吗
- 跨境电商,你准备好了吗?
- RSS来了,你准备好了吗?
- RSS来了,你准备好了吗?
- How to check the size of file/directory ?
- 数据结构 栈
- Struts2 OGNL使用详解
- erlang gen_event模板
- 第一篇博客
- 你准备好了吗?
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第3章节--SharePoint 2013 开发人员工具 网站设置
- 事件机制
- ie8中checkbox双边框问题
- 你是那种只看《XXXXX从入门到精通》的程序员吗?
- 设置 select 选中值不可改动,即只读
- uitableview自定义cell,cell加载图片
- LINUX下如何增加swap分区的大小
- vs2010生成和使用.dll,.lib和.exe文件