#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef vector VL; typedef pair PI; const ll mod = 1e9 + 7; /* * Sparse Table. * BiOp should be the type of a binary operator which is * associative, commutative and idempotent. * (For example, min and gcd satisfy them.) * Header Requirement: vector, cassert * Verified by: AtCoder ARC023 D (http://arc023.contest.atcoder.jp/submissions/960757) */ template class SparseTable { private: BiOp biop; std::vector > st; void create_sparse_table(int n, const std::vector &lcp) { int h = 1; while ((1 << h) < n) { ++h; } st = std::vector >(h + 1, std::vector(n)); for (int i = 0; i < n; ++i) { st[0][i] = lcp[i]; } for (int j = 1; j <= h; ++j) { for (int i = 0; i <= n - (1 << j); ++i) { st[j][i] = biop(st[j - 1][i], st[j - 1][i + (1 << (j-1))]); } } } /* * Reference: https://graphics.stanford.edu/~seander/bithacks.html#IntegerLogFloat * Please be aware that it only works well in case of 1 <= t <= 2^24. */ static int top_bit(int t) { const float v = t; // find int(log2(v)), where v > 0.0 && finite(v) && isnormal(v) int c; // 32-bit int c gets the result; c = *(const int *) &v; // OR, for portability: memcpy(&c, &v, sizeof c); return (c >> 23) - 127; } public: /* * Initializes this sparse table. O(n log n) where n = ary.size(). */ SparseTable(BiOp biop, const std::vector &ary): biop(biop) { create_sparse_table(ary.size(), ary); } /* * Computes biop(ary[f], ary[f+1], ..., ary[s]). O(1). * Note: the interval is inclusive. */ T query(int f, int s) const { assert (f <= s); int diff = top_bit(s + 1 - f); return biop(st[diff][f], st[diff][s + 1 - (1 << diff)]); } }; struct mymax { ll operator()(ll x, ll y) const { return max(x, y); } }; int main(void){ int n, d; ll k; cin >> n >> d >> k; VL x(n); REP(i, 0, n) { cin >> x[i]; } SparseTable spt(mymax(), x); ll ma = 0; int mini1 = -1; REP(i, 0, n) { ll a = x[i]; ll y = spt.query(i, min(i + d, n - 1)); if (y <= a) { continue; } ll t = y - a; if (ma < t) { ma = t; mini1 = i; } } if (ma == 0) { cout << 0 << endl; return 0; } cout << ma * k << endl; cout << mini1 << " "; int mini2 = -1; REP(i, mini1, min(mini1 + d + 1, n)) { if (ma + x[mini1] == x[i]) { mini2 = i; break; } } assert (mini2 >= 0); cout << mini2 << endl; }