SPRING TOURNAMENT IN INFORMATICS Yambol, 13 June 2009. Group a (11-12) Task A3. SMOOTHNESSThe hacker Pathi wants to build a House on a desolate coastal strip, which isN m long. The Strip is divided into segments with a length of one meter, numberedfrom left to right with the numbers from 1 to N, each segment has the altitude —a nonnegative integer. Asif wants his house to a long walk and K targetWe have a stretch of K consecutive segments of equal altitude. Of course,It is possible to strip, there is no such division. That's why Asif had hired cutting-edgetechnique, with which you can carry out the following two operations: to increase or decreasethe altitude of the route with the unit. The price of each of the two operations isunit. It is possible that the application of the multiple operations on the samesegment. Write a program that finds flatten at what minimum price Lavoiecan you provide k consecutive segments of equal altitude and numberon the segment, where it will begin his house (that is, the number of the leftmost of these kconsecutive segments).LoginThe first line of the standard input are defined natural numbers N and K in the second.line set N non-negative integers that are the altitudethe waterfront bars, arranged in ascending order of their numbers.ExitThe first line on the standard output the program should output the minimum pricethat can provide a Pathi k consecutive segments of equal altitude, andin the second row – the number of the segment, where it will begin his house. If there are severalstation K in length, whose alignment can be done at minimal cost, todisplay the number of the first line on the left of them.Restrictions5 ≤ N ≤ 1 000 000, 3 ≤ K ≤ N, and every stretch of coastline there is above sea levelheight of not more than 1 000 000.Limitation on memory-64 MB.EXAMPLE Input Output64 410 4 5 2 5 7 2------------------------- Converted by Unregistered Simpo PDF Converter -------------------------
đang được dịch, vui lòng đợi..