import sequtils,strutils,algorithm var L : seq[int] N,D,K : int X = newSeq[int](0) x,i,j :int L = stdin.readline.split.map(parseInt) (N, D, K) = (L[0], L[1], L[2]) for n in 0.. Max_be: day = d Max_be = InD[^1] - X[d] M = InD[^1] InD.delete(InD.binarySearch(X[d])) InD.insert(X[d + D + 1],InD.lowerBound(X[d + D + 1])) for d,price in X[high(X)-D..high(X)]: if InD[^1] - price > Max_be: day = high(X) - D + d Max_be = InD[^1] - X[d] M = InD[^1] InD.delete(InD.binarySearch(X[high(X) - D + d])) if day + D > high(X): j = high(X) else: j = day + D Bday = day for d,x in X[day..j]: if x == M: Sday = d + day break echo Max_be * K if Max_be > 0: echo Bday," ",Sday