Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

先排序

Posted by gemenhao at 2006-06-07 11:03:52 on Problem 2231
然后
 对于数组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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator