Cable Car

The Titiwangsa Mountains is a mountain range that forms the backbone of the Malay Peninsula. The Malaysian Cable Car (MCC) society has decided to build a cable car ropeway somewhere along the undeveloped mountain range, and has hired Fluffy the Squirrel to help with designing the ropeway.

There are N N mountains of heights h 1 , h 2 , , h N h_1, h_2, \ldots , h_N meters. Fluffy has to select two mountains to be the terminal stations. All the mountains in between the two selected mountains must be strictly shorter than both selected mountains, or else it would not be possible to build the ropeway.

To maximise the enjoyment of the ride, Fluffy wants to build the longest possible cable car ropeway. The length of a ropeway formed by selecting the i th i^\text{th} and j th j^\text{th} mountains ( i j ) (i \neq j) is defined as j i | j - i | . Your task is to help Fluffy determine the length of the longest possible cable car ropeway from the 6 mountains below.

1
3 4 1 2 5 6


This is one of my proposal for the Malaysian Computing Olympiad 2016 . Do try the problems there!


The answer is 3.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...