×

# Minimize the sum of absolute difference of adjacent array elements

 0 Given an array A of N (N<=10^6) elements , you can choose any subarray and invert the sign of all elements lying in that subarray i.e positive elements are changed to negative and vice versa. You have to apply this operation exactly once. Determine the minimum possible sum of absolute difference of adjacent array elements that can be obtained after applying the operation exactly once. -10^9<=A[i]<=10^9. Link to problem: http://codeforces.com/gym/101522/problem/I Please suggest how to approach this problem. asked 23 May '18, 22:18 3★lakh 139●5 accept rate: 23%

 2 Hi, I met you again, tips: when flipping symbols in the interval [L, R], the effect on the answer only exists at the endpoint, for example, when flipping the entire array, the answers was not changed. so the next steps are obvious。 answered 23 May '18, 22:54 6★freeloop 344●3 accept rate: 47% Thanks for the help mr. freeloop. (23 May '18, 22:58) lakh3★ 1 exactly man... :) I just opened this tab for writing that answer.. (23 May '18, 23:06)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×836

question asked: 23 May '18, 22:18

question was seen: 143 times

last updated: 26 May '18, 15:47