程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Blue Bridge Cup [11th finals] Q & a python 100 points

編輯:Python

Remember the preparation time s = s + a, Time to leave e, take 3 Time periods are merged into 2 individual

set up basic[n] On behalf of n The total time of students

Let's assume that there is currently an optimal ranking , The first n Students and n + 1 Students' contribution to time is :

best = 2 * ( basic[n - 1] + e[n - 1] + s[n] ) + e[n] + s[n + 1]

Now exchange No n Students and No n + 1 The position of students , The first n Students and n + 1 Students' contribution to time is :

new = 2 * ( basic[n - 1] + e[n - 1] + s[n + 1] ) + e[n + 1] + s[n]

Because the first is the optimal sort , So satisfy best < new, have to s[n] + e[n] < s[n + 1] + e[n + 1]

So according to sum([s, a, e]) You can get the correct sort by sorting

Full marks end  


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved