Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: K-Monotonic
Description A sequence of integer numbers is called strictly monotonically increasing if every term of the sequence is strictly greater than the one preceding it. Similarly, a sequence is called strictly monotonically decreasing if every term is strictly less than the one preceding it. A strictly monotonic sequence is a sequence that is either strictly monotonically increasing or decreasing. A sequence of integers is called For example a strictly monotonically increasing sequence is 1-monotonic — in fact it is If a sequence is not k, you are to calculate the minimum number of operations required to transform the given sequence into a k-monotonic sequence.Input The input contains multiple test cases. Each test case contains consists of two lines. The first line gives the integers A ≤ 100 000)._{i}A pair of zeroes indicates the end of the input and should not be processed. Output Output the answer of each test case on a separate line. Sample Input 4 1 1 1 1 1 4 2 1 1 1 1 4 4 1 1 1 1 6 1 1 2 3 3 2 1 0 0 Sample Output 4 2 0 9 Source POJ Monthly--2006.09.29, ACRush, modified from TopCoder SRM 309 KMonotonic |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator