class Solution:
def maxSubsequence(self, nums: List[int], k: int) -> List[int]:
n =len(nums)
s = []
# 所有数存为二元组(值,下标)
for i in range(n):
s.append((nums[i], i))
s.sort(key = lambda x : -x[0]) # 按值排倒序
s = s[:k] #取前k个
s.sort(key = lambda x: x[1]) # 再按下标排序
return [e[0] for e in s] # 只把值写入