Блог пользователя lovro-sinda

Автор lovro-sinda, 12 лет назад, По-английски

Can anyone help with this task.

Given a sequence of N different integers. Operations allowed members of the series are:

  • Move to the beginning of the sequence

  • Move to the end of the sequence

Print the smallest number of necessary operations to a default set of ascending sorted.

For example:

Input

4

3 4 2 1

Output

2

Thank you.

Теги dp, task
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

We move first 2 on the top

2 3 4 1

And in second move we move 1 on the top.

1 2 3 4

And answer is 2.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think it was quite clear because text said ** different integers** . So with that assumption you could easily understand what is start sequence.

So I'll remember this suggestions for next time.