#include #include using namespace std; struct segtree{ using segclass = pair; const segclass def = make_pair(0, 0); segclass compare(const auto& left, const auto& right){ if(left.first > right.first) return left; if(left.first == right.first && left.second >= right.second) return left; return right; } int n = 1; vector tree; segtree(int n_){ while(n_ > (n <<= 1)); n <<= 1; tree = vector(n - 1, def); n >>= 1; } segclass get(int k){ return tree[k + n - 1]; } void update(int k, segclass a){ k += n - 1; tree[k] = a; while(k > 0){ k = (k - 1) / 2; tree[k] = compare(tree[2 * k + 1], tree[2 * k + 2]); } } segclass query(int a, int b, int k, int l, int r){ if(r <= a || b <= l) return def; if(a <= l && r <= b) return tree[k]; else{ auto vl = query(a, b, 2 * k + 1, l, (l + r) / 2); auto vr = query(a, b, 2 * k + 2, (l + r) / 2, r); return compare(vl, vr); } } }; int main(){ int n, d, k; cin >> n >> d >> k; segtree seg(n); for(int i = 0, x; i < n && cin >> x; i++) seg.update(i, make_pair(x, i)); pair> ans(0, make_pair(0, 0)); for(int i = 0; i < n; i++){ auto maxi = seg.query(i, min(n, i + d), 0, 0, n); if(ans.first < (maxi.first - seg.get(i).first) * k){ ans.first = (maxi.first - seg.get(i).first) * k; ans.second = make_pair(i, maxi.second); } } if(!ans.first){ cout << 0 << endl; return 0; } cout << ans.first << endl << ans.second.first << ' ' << ans.second.second << endl; }