早教吧作业答案频道 -->英语-->
英语翻译RanklistSortingYouaregiventhescoresofseveralplayersinacompetition.Yourtaskistocreatearanklistoftheplayers,sortedindecreasingorderbyscore.Unfortunately,thedatastructureusedforthelistofplayerssupportsonlyo
题目详情
英语翻译
Ranklist Sorting
You are given the scores of several players in a competition.Your task is to create a ranklist of the
players,sorted in decreasing order by score.
Unfortunately,the data structure used for the list of players supports only one operation,which
moves a player from position i to position j without changing the relative order of other players.If
i > j,the positions of players at positions between j and i − 1 increase by 1,otherwise if i < j the
positions of players at positions between i + 1 and j decrease by 1.
This operation takes i steps to locate the player to be moved,and j steps to locate the position
where he or she is moved to,so the overall cost of moving a player from position i to position j is
i + j.Here,positions are numbered starting with 1.
Determine a sequence of moves to create the ranklist such that the sum of the costs of the moves is
minimized.
Input
The input is read from a text file named sorting.in .The first line contains n (2
Ranklist Sorting
You are given the scores of several players in a competition.Your task is to create a ranklist of the
players,sorted in decreasing order by score.
Unfortunately,the data structure used for the list of players supports only one operation,which
moves a player from position i to position j without changing the relative order of other players.If
i > j,the positions of players at positions between j and i − 1 increase by 1,otherwise if i < j the
positions of players at positions between i + 1 and j decrease by 1.
This operation takes i steps to locate the player to be moved,and j steps to locate the position
where he or she is moved to,so the overall cost of moving a player from position i to position j is
i + j.Here,positions are numbered starting with 1.
Determine a sequence of moves to create the ranklist such that the sum of the costs of the moves is
minimized.
Input
The input is read from a text file named sorting.in .The first line contains n (2
▼优质解答
答案和解析
Ranklist排序
让用户有分数几名球员在竞争.你的任务是创造一个ranklist的
播放器,依次排序的评分.
不幸的是,数据结构用于支持名单的球员只有一个行动,
动作的球员从第一的位置不改变立场j的相对秩序的其他球员.如果
字母i “ J以来,立场球员之间的立场J和我- 1增加1 ,否则,如果我”的j
位置球员之间的立场一+ 1和J减少1 .
此操作步骤,字母i需要找到球员移动,和J步骤定位
他或她是搬到,所以总的成本移动位置的球员从第一的位置J的
一+学者在这里,职位的编号从1 .
确定序列的动作创造ranklist的款项等的费用,此举是
减少到最低限度.
输入
输入读取一个文本文件名为sorting.in .第一行包含ñ ( 2 “为N ” = 1000 ) ,
球员的数量.以下每个ñ行包含一个非负整数硅( 0 “ =市” =
1000000 ) ,得分球员在目前的秩序.你可以假设所有分数是不同的.
输出
输出写入一个文本文件名为sorting.out .第一行中的打印输出
一些动作用于创建ranklist .以下几行应指定动作的
为了在被应用.每个移动应予以说明的行包含两个整数字母i
和J ,这意味着球员的位置移动到第一的位置学者数字I和J必须
分隔的一个空间.
例如
sorting.in sorting.out
分级
30 %的测试案例有价值观的N “ = 10
让用户有分数几名球员在竞争.你的任务是创造一个ranklist的
播放器,依次排序的评分.
不幸的是,数据结构用于支持名单的球员只有一个行动,
动作的球员从第一的位置不改变立场j的相对秩序的其他球员.如果
字母i “ J以来,立场球员之间的立场J和我- 1增加1 ,否则,如果我”的j
位置球员之间的立场一+ 1和J减少1 .
此操作步骤,字母i需要找到球员移动,和J步骤定位
他或她是搬到,所以总的成本移动位置的球员从第一的位置J的
一+学者在这里,职位的编号从1 .
确定序列的动作创造ranklist的款项等的费用,此举是
减少到最低限度.
输入
输入读取一个文本文件名为sorting.in .第一行包含ñ ( 2 “为N ” = 1000 ) ,
球员的数量.以下每个ñ行包含一个非负整数硅( 0 “ =市” =
1000000 ) ,得分球员在目前的秩序.你可以假设所有分数是不同的.
输出
输出写入一个文本文件名为sorting.out .第一行中的打印输出
一些动作用于创建ranklist .以下几行应指定动作的
为了在被应用.每个移动应予以说明的行包含两个整数字母i
和J ,这意味着球员的位置移动到第一的位置学者数字I和J必须
分隔的一个空间.
例如
sorting.in sorting.out
分级
30 %的测试案例有价值观的N “ = 10
看了 英语翻译RanklistSo...的网友还看了以下:
下列各项中,加点字读音全对的一项是()A.口角jiǎo绿lù林结jiē巴落luò在后面B.眼眶ku 2020-05-13 …
matlab语法中 [m,n]=A(k:n,5) A 是一个矩阵 请问m,n 输出各代表什么含义? 2020-05-16 …
设A是n阶矩阵,若存在正整数k,使线性方程组A^kα=0有解向量,且A^(k-1)α≠0请问:为什 2020-05-16 …
设{an}是等差数列,Sn为其前n项和.若正整数i,j,k,l满足i+l=j+k(i≤j≤k≤l) 2020-06-12 …
我们称一个自然数n是“好数”,如果能找到两个非零自然数k,l(k,l可以相等),使得n=kl+l- 2020-06-12 …
A{n│n=2k+1,k∈Z}、B{m│m=2l-1,l∈Z}如果n∈A,那么存在k∈Z,使n=2k 2020-10-31 …
矩阵秩的问题,急n阶矩阵A满足A^2=I证明对任意正整数s,k有rank[(I-A)^s]+rank 2020-11-01 …
选出加点字读音全对的一组()A.拗(ǎo)断骄横(hèng)寥廓(kuò)埋(mán)怨B.看(kā 2020-11-10 …
编译原理文法L={a^nb^mc^kd^n|m,n,k≥1}问道题L={a^nb^mc^kd^n|m 2020-11-23 …
英语:下1.将下联打乱的字母组成单词,并写出汉语意思1.a,e,h,g,c,n[]2.e,i,s,t 2020-12-10 …