当前位置:网站首页>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;
}
边栏推荐
- Database security - create login user + configure permissions [notes]
- India plans to ban China Telecom equipment! Can we really do without Huawei and ZTE?
- What kind of knowledge payment system functions are more conducive to the development of the platform and lecturers?
- 3.用数组逆序打印链表
- Match file names from file paths using regular expressions
- 6、双指针——递增数组两数之和与目标数相等
- 用两个栈实现一个队列【C语言】
- 9. Delete nodes in the linked list
- Database mysql Foundation
- 3. Print the linked list in reverse order with the array
猜你喜欢
![Database security - create login user + configure permissions [notes]](/img/02/0c3eb542593e8e0a3a62db75c52850.png)
Database security - create login user + configure permissions [notes]

SQL Server 2016学习记录 --- 单表查询

SQL Server 2016 learning records - connection query

gcc: error trying to exec 'as': execvp: No such file or directory

PHP生成二维码(学习)

SQL Server 2016 学习记录 --- 数据定义

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

15、判断二维数组中是否存在目标值

6. Double pointer -- the sum of the two numbers of the incremental array is equal to the target number

Skillfully use NGX_ Lua makes traffic grouping
随机推荐
MySQL的SQL TRACE一例
Go 内存模型 (2014年5月31日版本)
12、双指针——合并两个有序链表
7. Dichotomy -- find a set of repeated or ordered but rotating arrays
3. Print the linked list in reverse order with the array
Uni app advanced creation component / native rendering
(1)机器学习概念总结
吴雄昂遭Arm罢免内幕:建私人投资公司,损害了股东利益?
逆元&组合数&快速幂
brief introduction
Aqua Data Studio 18.5.0导出insert语句
centos7下安装mysql,网上文章都不太准
gcc: error trying to exec 'as': execvp: No such file or directory
CentOS7下安装mysql5.7
2021-10-13arx
(1) Summary of machine learning concepts
13、哈希表——两个链表第一个公共节点
2020第二届传智杯初赛
C language secondary pointer explanation and example code
Vulnerability analysis hevd-0x8.integeroverflow[win7x86]