Counterexamples to Claim that A = (10,1,1,10) for B = (10,1,1,10)?

AI Thread Summary
The discussion centers on finding the maximum sum of absolute differences in a sequence defined by constraints on its elements. The user is confident that each element can only be 1 or its corresponding upper limit, bi. They explore two potential patterns for the sequence but seek counterexamples to validate their assumptions. A key insight is that while alternating patterns might seem optimal, they do not necessarily yield the maximum sum in all cases. The specific example of the sequence B = (10,1,1,10) illustrates the need for a more flexible approach in constructing sequence A.
SlurrerOfSpeech
Messages
141
Reaction score
11
I'm trying to solve a problem that amounts to:

Given b0, ..., bn-1 where1 <= bi, find the max of |a0 - a1| + |a1 - a2| + ... + |an-2 - an-1| where 1 <= ai <= bi.

I'm 100% confident that each ai is either 1 or bi.

I'm 90% confident that the elements a0, ..., an-1 are either

1, b0, 1, b1, ...,

or

b0, 1, b1, 1, ...

Are there any simple counterexamples?
 
Technology news on Phys.org
Can you give a context for your question? Is this some intuitive problem or is it based on some concrete example that someone might already know about?
 
SlurrerOfSpeech said:
Are there any simple counterexamples?

it's easy to see, that for all ai-1 and ai+1, ai has to be 1 or bi.
- if ai is smaller than both ai-1 and ai+1, setting it to 1 will make the sum bigger.
- if ai is biggger than both ai-1 and ai+1, setting it to bi will make the sum bigger.
- if ai is between ai-1 and ai+1 setting it to 1 or to bi
will make the sum bigger.
The only case where the last possibility doesn't work, is when one of the neigbours is 1 and the other >= b. In that case the maximum sum is the same whatever ai is.
You can force such a situation with a 1,2,3,1 sequence. a1 can be anything <=2.
A non-conforming sequence with a larger sum of differences isn't possible.
 
jedishrfu said:
Can you give a context for your question? Is this some intuitive problem or is it based on some concrete example that someone might already know about?

An algorithms problem I'm trying to solve https://www.hackerrank.com/challenges/sherlock-and-cost

The solution I tried is essentially

X = [1, b0, 1, b1, ... ]
Y =[b0, 1, b1, 1, ... ]
max(diffs(X), diffs(Y)]

and was surprised that it didn't pass all test cases.
 
  • Like
Likes jedishrfu
To get the maximum, all ai can be either 1 or bi, but it doesn't have to be an alternating pattern of 1s and bis.
B = (10,1,1,10) needs A = (10,1,1,10)
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Back
Top