class SegmentTree: """ https://qiita.com/dn6049949/items/afa12d5d079f518de368 から拝借しています。 """ def __init__(self, size, f=lambda x, y: max(x, y), default=0): self.size = 2 ** (size - 1).bit_length() self.default = default self.dat = [default] * (self.size * 2) self.f = f def update(self, i, x): i += self.size self.dat[i] = x while i > 0: i >>= 1 self.dat[i] = self.f(self.dat[i * 2], self.dat[i * 2 + 1]) def query(self, l, r): """半開区間[l,r)""" l += self.size r += self.size lres, rres = self.default, self.default while l < r: if l & 1: lres = self.f(lres, self.dat[l]) l += 1 if r & 1: r -= 1 rres = self.f(self.dat[r], rres) l >>= 1 r >>= 1 res = self.f(lres, rres) return res N, D, K = map(int, input().split()) S = SegmentTree(N + 1) X = [int(input()) for _ in range(N)] for i, x in enumerate(X, 1): S.update(i, x) p_max = 0 lidx = 0 for i, x in enumerate(X, 1): M = S.query(i, min(i + D, N) + 1) profit = K * (M - x) if p_max < profit: p_max = profit lidx = i - 1 print(p_max) if p_max: M = X[lidx] + p_max // K ridx = X[lidx:min(lidx + D + 1, N)].index(M) + lidx print(lidx, ridx)