//以下を参考にした //https://yukicoder.me/wiki/auto_vectorization #ifdef __GNUC__ #pragma GCC optimize ("O3") #pragma GCC target ("avx") #endif #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include //#include //x C++ (G++ 4.6.4) #include #include #include #include #include #include #include //assert(); #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #define PII pair ///////// using namespace::std; // 最大公約数 template inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;} //inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);} // 最小公倍数 template inline T lcm(T a, T b){return a / gcd(a, b) * b;} //inline T lcm(T a, T b){return a * b / gcd(a, b);} //////////////////////////////// class segment{ int n; //nは2のべき乗 int MAX_VAL; vector< pair > dat;//first:val second:index public: int getN(){return n;} void init(int N,int MAX_num){//N:要素数,最大値 MAX_VAL = MAX_num; n = 2; while(n < N ){ n <<= 1; } dat.assign(2*n-1,pair(MAX_VAL,-1)); } void update(int i,int x){ i += n-1;//葉のノード番号 dat[i] = pair(x,i -(n-1));//値を更新,index while(i>0){ i = (i-1)/2; if( dat[i*2+1].first <= dat[i*2+2].first ){ dat[i] = dat[i*2+1]; }else{ dat[i] = dat[i*2+2]; } } } //query(a,b,0,0,n) pair query(int a,int b,int k,int l,int r){ if(r<=a || b<=l){ return pair(MAX_VAL,-1);//交差しない } if(a<=l && r<=b)return dat[k]; else{ pair vl = query(a,b,k*2+1,l,(l+r)/2); pair vr = query(a,b,k*2+2,(l+r)/2,r); if( vl.first <= vr.first ){ return vl; }else{ return vr; } } } }; void solve(){ LL N,D,K; cin >> N >> D >> K; segment seg; seg.init((int)N,1000001); vector X((int)N+1); for(int i=0;i> X[i]; seg.update(i,-X[i]); } LL MAX = -1; int posL = -1; int posR = -1; for(int i=0;i res = seg.query(i,i+(int)D,0,0,(int)N); LL temp = -res.first; temp -= X[i]; if( temp > MAX ){ MAX = temp; posL = i; posR = res.second; } } LL ans = MAX * K; if( MAX > 0 ){ cout << ans << endl; cout << posL << " " << posR << endl; }else{ cout << 0 << endl; } } signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); //std::cout << std::fixed;//小数を10進数表示 //cout << setprecision(16);//小数点以下の桁数を指定 solve(); }