#include using namespace std; #ifdef LOCAL_ void debug_out() { cerr << "\033[0m" << endl; } template void debug_out(Head H, Tail... T) { cerr << ' ' << H << ','; debug_out(T...); } #define debug(...) cerr << "\033[1;36m" << __func__ << ":L" << __LINE__ << " " << #__VA_ARGS__ << ":", debug_out(__VA_ARGS__) #define dump(x) cerr << __func__ << ":L" << __LINE__ << " " << #x << " = " << (x) << endl #else #define debug(...) (void(0)) #define dump(x) (void(0)) #endif #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define irep(i, n) for (int i = (int)(n)-1; i >= 0; --i) using ll = long long; using pii = pair; using pil = pair; using pli = pair; using pll = pair; constexpr int INF = 1000'000'000; constexpr long long HINF = 4000'000'000000'000'000; constexpr long long MOD = 1000000007; // = 998244353; constexpr double EPS = 1e-4; constexpr double PI = 3.14159265358979; #pragma region Macros template ostream &operator<<(ostream &os, const pair &p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template ostream &operator<<(ostream &os, const vector &v) { os << '['; for (auto &e : v) { os << e << ','; } os << ']'; return os; } template ostream &operator<<(ostream &os, const set &st) { os << '{'; for (auto itr = st.begin(); itr != st.end(); itr++) { os << *itr << ','; } os << '}'; return os; } template ostream &operator<<(ostream &os, const map &mp) { os << '{'; for (auto itr = mp.begin(); itr != mp.end(); itr++) { os << itr->first << ": " << itr->second << ','; } os << '}'; return os; } void yn(bool cond, string Yes = "Yes", string No = "No") { cout << (cond ? Yes : No) << '\n'; } template bool chmax(T &x, const T &y) { return (x < y) ? (x = y, true) : false; } template bool chmin(T &x, const T &y) { return (x > y) ? (x = y, true) : false; } #pragma endregion // SlidingWindowAggregation // 半群に対して以下のことが行えるデータ構造 // // push(x): xを追加する // pop(): queueの要領で要素を取り除く(FIFO) // fold(): 今入っている要素を早く入っていた方からa0,a1,...,anとしたときにa0*a1*...anを計算する. template struct SlidingWindowAggregation { using Fx = function; vector left, left_cum, right, right_cum; Fx op; SlidingWindowAggregation(Fx op) : op(op) {} inline int size() { return (int)left.size() + (int)right.size(); } inline bool is_empty() { return size() == 0; } // push // xを追加する // 計算量: O(1) void push(SemiGrp x) { if ((int)right.size() == 0) { right.push_back(x); right_cum.push_back(x); } else { right.push_back(x); right_cum.push_back(op(right_cum.back(), x)); } } // pop // データをFIFOで取り出す. 空の場合は何もしない. // 計算量: 償却 O(1) void pop() { if (is_empty()) return; if ((int)left.size() != 0) { left_cum.pop_back(); left.pop_back(); return; } int sz = (int)right.size(); left.push_back(right.back()); left_cum.push_back(right.back()); right.pop_back(); for (int i = 1; i < sz - 1; i++) { left.push_back(right.back()); left_cum.push_back(op(right.back(), left_cum.back())); right.pop_back(); } if (sz > 1) right.pop_back(); } // fold // 今入っている要素を早く入っていた方からa0,a1,...,anとしたときにa0*a1*...anを返す. // 制約: 空ではない // 計算量: O(1) SemiGrp fold() { assert(!is_empty()); if ((int)left.size() == 0) return right_cum.back(); else if ((int)right.size() == 0) return left_cum.back(); else return op(left.back(), right.back()); } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int n, d, k; cin >> n >> d >> k; vector X(n); for (int i = 0; i < n; i++) cin >> X[i]; using SemiGrp = pair; SlidingWindowAggregation swag([](const SemiGrp &a, const SemiGrp &b) { if (a.first < b.first) return b; else return a; }); int max_diff = 0; int ai = -1, bi = -1; for (int i = 0; i <= d; i++) swag.push({X[i], i}); for (int i = 0; i < n; i++) { auto [x, j] = swag.fold(); if (max_diff < x - X[i]) { max_diff = x - X[i]; ai = i, bi = j; } swag.pop(); if (i + d + 1 < n) swag.push({X[i + d + 1], i + d + 1}); } if (max_diff == 0) cout << 0 << '\n'; else { cout << (long long)k * max_diff << '\n'; cout << ai << ' ' << bi << '\n'; } return 0; }