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

其实很水的,直接排个序就可以O(n)解决了。

Posted by duanxian0621 at 2011-08-01 08:58:08 on Problem 3663
原因:a1<=a2<=a3<=a4<=a5<=.....an;
对于a1,从序列an开始递减查找,找到第一个aj+a1<=S的话,那么ans+=j-1,跳出。
对于a2,则只要从序列aj开始递减查找就可以了。
......
当j>i的情况下,按照上面的方式查找,每次ans+=j-i即可。

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