当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

uni-app项目目录、文件作用介绍 及 开发规范

Match file names from file paths using regular expressions

6、双指针——递增数组两数之和与目标数相等

14、双指针——盛最多水的容器

SQL Server 2016 learning record - Data Definition

Aqua Data Studio 18.5.0导出insert语句

SQL Server 2016 学习记录 --- 集合查询

用两个栈实现一个队列【C语言】

ACM寒假集训#6

Idea packages jar packages and runs jar package commands
随机推荐
4. Adjust the array order so that odd numbers precede even numbers
Continue to write the greatest work based on modelarts [play with Huawei cloud]
阿里云镜像地址
How to write Ogg with multiple filter syntax?
India plans to ban China Telecom equipment! Can we really do without Huawei and ZTE?
IE兼容性问题处理
ACM寒假集训#4
第一篇:UniAPP的小程序跨端开发-----创建uniapp项目
字符串匹配
django-celery-redis异步发邮件
10、链表中倒数第k个节点
Talk about the problem of preventing others from debugging websites through console based on JS implementation
发力大核、独显!英众科技2020十代酷睿独显产品发布
12. Double pointer -- merge two ordered linked lists
3. Print the linked list in reverse order with the array
在mt6735中添加新的开机logo与开\关机动画
Xu Ziyang, President of ZTE: 5nm chip will be launched in 2021
9. Delete nodes in the linked list
Detailed explanation of super complete knowledge points of instruction system
Ie compatibility problem handling