Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
先排序然后 对于数组a[n]中的第i个数 前面有 i - 1处于被减, 后面有 n - i为减数(忘了是不是) a[i]对于总和的贡献就是 sum += (__int64)cow[i] * (2*i - 1 - n ); 结果再乘2 时间复杂度为排序 n*(lgn) 不知是否有 o(n)算法? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator