当前位置:网站首页>HJ score ranking
HJ score ranking
2022-06-28 07:38:00 【Courageous steak】
Knowledge point : Sort
describe
Give some information about students ( name , achievement ) Sequence , Please rank their information from high to low or from low to high , Same score
All are processed according to the rules entered first and arranged first .
Example :
jack 70
peter 96
Tom 70
smith 67
From high to low achievement
peter 96
jack 70
Tom 70
smith 67
From low to high
smith 67
jack 70
Tom 70
peter 96
notes :0 Represents from high to low ,1 Represents from low to high
Data range : The number of :1\le n \le 200\1≤n≤200
Advanced : Time complexity :O(nlogn)\O(nlogn) , Spatial complexity :O(n)\O(n)
Input description :
In the first line, enter the number of people to sort n, In the second line, enter an integer to indicate the sorting method , after n Enter their names and grades on each line , Separated by a space
Output description :
Output the name and grade in the specified way , Name and grade are separated by a space
Example 1
Input :3
0
fang 90
yang 50
ning 70
Output :fang 90
ning 70
yang 50
Example 2
Input :3
1
fang 90
yang 50
ning 70
Output :
yang 50
ning 70
fang 90
Cattle guest HJ Python
# The elapsed time 44ms Take up memory 4648KB
n = int(input())
t = int(input())
l = []
for i in range(n):
name,score = input().split()
l.append((name, int(score)))
if t == 1:
l.sort(key=lambda x:x[1], reverse=False)
else:
l.sort(key=lambda x:x[1], reverse=True)
for i in l:
print(i[0],i[1])
Link to the original text :
https://www.920vip.net/article/180
边栏推荐
- HJ整数与IP地址间的转换
- QT -- communication protocol
- Source code analysis of kubernetes' process of deleting pod
- Section 9: dual core startup of zynq
- Practice and exploration of vivo live broadcast application technology
- Mysql8.0 and mysql5.0 accessing JDBC connections
- flex布局
- HJ字符个数统计
- Devtools implementation principle and performance analysis practice
- Rediscluster cluster mode capacity expansion node
猜你喜欢

Unity UI shadow component

Rediscluster cluster mode capacity expansion node

Spark 离线开发框架设计与实现

kubelet驱逐机制的源码分析

分析 NFT 项目的 5 个指标

Jetpack - defects of livedata component and Countermeasures

kubernetes集群命令行工具kubectl

Top 25 most popular articles on vivo Internet technology in 2021

以动态规划的方式求解最长回文子串

网传互联网公司加班表,排名第一的没悬念
随机推荐
腾讯下半年继续裁员,所有事业群至少缩减 10%,对此你怎么看?关注者
HJ字符串排序
Kubernetes理论基础
Evolution of vivo push platform architecture
A gadget can write crawlers faster
东方财富上开户是安全的吗
golang gin框架进行分块传输
扩展Prometheus的解决方案thanos的简介和几个月使用心得
Unity UI shadow component
Co process, asyncio, asynchronous programming
Leetcode learning records
基金的投资交易与结算
[ thanos源码分析系列 ]thanos query组件源码简析
安全培训是员工最大的福利!2022新员工入职安全培训全员篇
云原生(待更新)
es数据导出csv文件
Evaluation of inverse Polish expression < difficulty coefficient >
A single node obtains the lock lock of the order number
HJ整数与IP地址间的转换
Top 25 most popular articles on vivo Internet technology in 2021