package yukicoder; import java.awt.List; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; public class Q485 { static int N, D; static long K; static int[] x; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); D = sc.nextInt(); K = sc.nextInt(); x = new int[N]; for (int i = 0; i < N; ++i) { x[i] = sc.nextInt(); } MonotonicPriorityQueue mpq = new MonotonicPriorityQueue(); for (int i = 1; i <= Math.min(D, N); ++i) { mpq.push(x[i], i); } long maxProfit = 0; long srcDay = -1; long dstDay = -1; for (int i = 0; i + 1 < N; ++i) { if (maxProfit < (mpq.pop().val - x[i]) * K) { maxProfit = (mpq.pop().val - x[i]) * K; srcDay = i; dstDay = mpq.pop().day; } mpq.poll(); if (i + D + 1 < N) mpq.push(x[i + D + 1], i + D + 1); } if (maxProfit > 0) { System.out.println(maxProfit); System.out.println(srcDay + " " + dstDay); } else { System.out.println(0); } } static class MonotonicPriorityQueue { class Pair { long val, day, cnt; public Pair(long val, long cnt, long day) { this.val = val; this.cnt = cnt; this.day = day; } } ArrayDeque que = new ArrayDeque<>(); void push(int val, long day) { int cnt = 0; while (!que.isEmpty() && que.getLast().val < val) { cnt += que.getLast().cnt + 1; que.pollLast(); } que.addLast(new Pair(val, cnt, day)); } Pair pop() { return que.getFirst(); } Pair poll() { Pair ret = pop(); if (que.getFirst().cnt > 0) { --que.getFirst().cnt; } else { que.pollFirst(); } return ret; } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }