当前位置:网站首页>SDUT 2446 最终排名
SDUT 2446 最终排名
2022-07-28 10:15:00 【小柳学渣】
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
第四届山东理工大学ACM网络编程擂台赛比赛完后需要产生一个最终排名,排名按照题数多少来决定。但是有太多的队伍参与,手动计算排名已经不能满足比赛的需求。现在有一份名单记录各个队伍的ID和做出的题目数,需要你写一个程序,产生最终的排名。
为了简化题目,这里的排名规则为:做出题目数量多的队伍排在前面,如果题数相等,保持输入时的相对顺序不要改变。 Input
第一行包含一个正整数T( 1 ≤ T ≤ 15),表示有T组测试数据。每组数据第一行有一个正整数N(1 < N ≤
10000),表示队伍数量。接下来N 行包含两个整数,1 ≤ ID ≤ 10^7, 0 ≤ M ≤
100。ID为队伍的编号,M为做出的题数。
Output
每组数据输出包含N行,第i行有两个整数,ID和M表示排在第i位的队伍的ID和做出的题数。
Sample Input
1
8
1 2
16 3
11 2
20 3
3 5
26 4
7 1
22 4
Sample Output
3 5
26 4
22 4
16 3
20 3
1 2
11 2
7 1
Hint
Source
#include <iostream>
#include <algorithm>
using namespace std;
struct s{
int a,b,c;
};
int c(s a,s b)
{
if(a.b==b.b){
return a.c<b.c;
}
return a.b>b.b;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int m;
cin>>m;
s s[m];
for(int i=0;i<m;i++)
{
cin>>s[i].a>>s[i].b;
s[i].c=i;
}
sort(s,s+m,c);
for(int i=0;i<m;i++)
{
cout<<s[i].a<<" "<<s[i].b<<endl;
}
}
return 0;
}
边栏推荐
- 5、动态规划---斐波那契数列
- SQL Server 2016 学习记录 --- 集合查询
- 胡润发布2020中国芯片设计10强民营企业:华为海思竟然没有上榜!
- 10 minute quick start EVs [play Huawei cloud]
- Small knowledge in Oracle
- 吴雄昂遭Arm罢免内幕:建私人投资公司,损害了股东利益?
- SQL Server 2016 learning records - connection query
- How to write Ogg with multiple filter syntax?
- Vulnerability analysis hevd-0x8.integeroverflow[win7x86]
- Alibaba cloud image address
猜你喜欢
随机推荐
Typora tutorial
2020第二届传智杯初赛
Hurun released the 2020 top 10 Chinese chip design private enterprises: Huawei Hisilicon did not appear on the list!
ACM寒假集训#4
Get to know SuperMap idesktop for the first time
吴雄昂遭Arm罢免内幕:建私人投资公司,损害了股东利益?
ACM寒假集训#5
Bitwise and, or, XOR and other operation methods
2. 输出数组中重复的数字之一
9、删除链表中节点
华为入股石墨烯材料厂商富烯科技,持股10%
ogg参数filter的使用问题【急】
jvm原理
Idea packages jar packages and runs jar package commands
5. Dynamic programming -- Fibonacci series
gcc: error trying to exec 'as': execvp: No such file or directory
Uni app advanced creation component / native rendering
[cloud co creation] enterprise digital transformation, Huawei cloud consulting is with you
第一篇:UniAPP的小程序跨端开发-----创建uniapp项目
中兴通讯:5nm 5G基站芯片正在技术导入!









