#P3411. 序列变换
序列变换
Description
Given a sequence of length .
You may perform several operations. In each operation, you can choose any number in the sequence and move it to the beginning or to the end of the sequence.
Find the minimum number of operations needed to make the sequence non-decreasing. "Non-decreasing" means that every number in the sequence is not greater than the number that follows it.
Input Format
The first line contains a positive integer .
The second line contains positive integers .
Output Format
Output a single integer, representing the minimum number of operations required.
5
6 3 7 8 6
2
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号