Created
October 14, 2014 04:04
-
-
Save broqdev/69be1f7be7d869e3ac6c to your computer and use it in GitHub Desktop.
Revisions
-
broqdev created this gist
Oct 14, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ 当前是i,j in [0...i),first pass算max(A[i]+A[j]+i-j),second pass 算max(A[i]+A[j]+n-(i-j)) 第一次用公式max_value = max(max_value+1, A[i-1]+1) 第二次用公式max_value = max(max_value-1, A[i-1]+n-1) for i in xrange(len(ar)): #try to update max_value ret = max(ret, A[i]+max_value) 这个循环写两次,用两个不同的公式