#include #include using namespace std; struct Quote { Quote(long long price, int date) : price(price), date(date) {} long long price; int date; }; bool operator<(const Quote& lhs, const Quote& rhs) { if (lhs.price != rhs.price) { return lhs.price < rhs.price; } return lhs.date > rhs.date; } int main(int argc, const char * argv[]) { int n, d; long long k; cin >> n >> d >> k; long long x[1000000]; for (int i = 0; i < n; ++i) { cin >> x[i]; } priority_queue max; for (int i = 0; i < d - 1; ++i) { max.push(Quote(x[i], i)); } long long maxProfit = 0; int maxIn = 0, maxOut = 0; for (int i = 0; i < n; ++i) { if (i + d < n) { max.push(Quote(x[i + d], i + d)); } while (max.top().date < i) { max.pop(); } long long profit = max.top().price - x[i]; if (maxProfit < profit) { maxProfit = profit; maxIn = i; maxOut = max.top().date; } } cout << (maxProfit * k) << endl; if (maxProfit > 0) { cout << maxIn << " " << maxOut << endl; } return 0; }