Boring Tim
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 7
Solved: 3
[Submit][STATUS][Web Board]
Description
Tim is study in Children of Primary School of Hunan Agricultural University. In this summer vacation, he didn`t get any homework.And he can`t go to Internet cafes to play LOL game because of he isn`t an adult. He looked at his report card. He hopes his grades are rising. So that he want to delete some score. He call this report card is a good report. specially when these score are an arithmetic sequence, he will be very happy and call it a great report. Could you tell him to make the report to be a great report how many score he need delete at least?
Input
There are many tests.For each test the first line is an integer N(2<=N<=1,000),in the second line there are N integer Di(Di<=1,000). When the number N is zero the input is over and you needn`t del this test.
Output
A sample number which is the minimun number of delete.
Sample Input
4
1 3 2 4
5
11 22 44 33 55
0
Sample Output
2
2
思路:增加一维记录公差,然后再做最长求最长单调递增子序列即可。 这题输出的是n-最长等差子序列长度。