1323 - 排队打水问题

通过次数

0

提交次数

0

Time Limit : 1 秒
Memory Limit : 128 MB

 

<span style="font-family:Arial;color:black;font-size:20pt;"><span>&nbsp;&nbsp;&nbsp; </span></span><span style="font-family:宋体;color:black;font-size:20pt;">有</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:Arial;color:black;font-size:20pt;">(n&lt;=100)</span><span style="font-family:宋体;color:black;font-size:20pt;">个</span><span style="font-family:宋体;color:black;font-size:20pt;">人在一个水龙头前排队接水,假如每个人接水的时间为</span><span style="font-family:Arial;color:black;font-size:20pt;">Ti</span><span style="font-family:Arial;color:black;font-size:20pt;">(Ti&lt;=1000)</span><span style="font-family:宋体;color:black;font-size:20pt;">,</span><span style="font-family:宋体;color:black;font-size:20pt;">请编程找出这</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:宋体;color:black;font-size:20pt;">个人排队的一种顺序,使得</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:宋体;color:black;font-size:20pt;">个人的平均等待时间最小。</span><span style="font-family:Arial;color:black;font-size:20pt;font-weight:bold;"> </span>

Input

 

<span style="font-family:Arial;color:black;font-size:20pt;"><span>&nbsp;&nbsp;&nbsp; </span></span><span style="font-family:宋体;color:black;font-size:20pt;">输入文件共两行,第一行为</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:宋体;color:black;font-size:20pt;">;第二行分别表示第</span><span style="font-family:Arial;color:black;font-size:20pt;">1</span><span style="font-family:宋体;color:black;font-size:20pt;">个人到第</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:宋体;color:black;font-size:20pt;">个人每人的接水时间</span><span style="font-family:Arial;color:black;font-size:20pt;">T1</span><span style="font-family:宋体;color:black;font-size:20pt;">,</span><span style="font-family:Arial;color:black;font-size:20pt;">T2</span><span style="font-family:宋体;color:black;font-size:20pt;">,</span><span style="font-family:Arial;color:black;font-size:20pt;">…</span><span style="font-family:宋体;color:black;font-size:20pt;">,</span><span style="font-family:Arial;color:black;font-size:20pt;">Tn</span><span style="font-family:宋体;color:black;font-size:20pt;">,每个数据之间有</span><span style="font-family:Arial;color:black;font-size:20pt;">1</span><span style="font-family:宋体;color:black;font-size:20pt;">个空格。</span><span style="font-family:Arial;color:black;font-size:20pt;font-weight:bold;"> </span>

Output

 

<span style="font-family:Arial;color:black;font-size:20pt;"><span>&nbsp;&nbsp;&nbsp; </span></span><span style="font-family:宋体;color:black;font-size:20pt;">输出文件有两行,第一行为一种排队顺序,即</span><span style="font-family:Arial;color:black;font-size:20pt;">1</span><span style="font-family:宋体;color:black;font-size:20pt;">到</span><span style="font-family:Arial;color:black;font-size:20pt;">n</span><span style="font-family:宋体;color:black;font-size:20pt;">的一种排列;第二行为这种排列方案下的平均等待时间</span><span style="font-family:Arial;color:black;font-size:20pt;">(</span><span style="font-family:宋体;color:black;font-size:20pt;">输出结果精确到小数点后两位</span><span style="font-family:Arial;color:black;font-size:20pt;">)</span><span style="font-family:宋体;color:black;font-size:20pt;">。</span><span style="font-family:Arial;color:black;font-size:20pt;font-weight:bold;"> </span>

Examples

Input

10
56 12 1 99 1000 234 33 55 99 812 

Output

3 2 7 8 1 4 9 6 10 5
532.00 		

Source

初一