#include #include #include using namespace std; 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(make_pair(x[i], i)); } long long maxProfit = 0; int maxIn = 0, maxOut = 0; for (int i = 0; i < n - d; ++i) { max.push(make_pair(x[i + d], i + d)); while (max.top().second < i) { max.pop(); } long long profit = max.top().first - x[i]; if (maxProfit < profit) { maxProfit = profit; maxIn = i; maxOut = max.top().second; } } cout << (maxProfit * k) << endl; if (maxProfit > 0) { cout << maxIn << " " << maxOut << endl; } return 0; }