#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair const int inf = 1000000001; const ll INF = 1e18 * 2; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<> n >> d >> k; vi x(n); for (i = 0; i < n; i++) { cin >> x[i]; } ll ans = 0; ll buyd, selld; deque dq; for (i = 0; i <= d; i++) { while (!dq.empty()){ if (dq[dq.size() - 1] < x[i]) { dq.pop_back(); } else { break; } } dq.push_back(i); } for (i = 0; i < n; i++) { if (ans < (x[dq[0]] - x[i])*k) { ans = (x[dq[0]] - x[i])*k; buyd = i; selld = dq[0]; } if (i + d + 1 < n) { while (!dq.empty()) { if (dq[dq.size() - 1] < x[i + d + 1]) { dq.pop_back(); } else { break; } } } dq.push_back(i + d + 1); while (!dq.empty()) { if (dq[0] <= i) { dq.pop_front(); } } } cout << ans << endl; if (ans) { cout << buyd << " " << selld << endl; } }