結果

問題 No.489 株に挑戦
ユーザー ixmelixmel
提出日時 2017-02-24 22:48:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 68 ms / 1,000 ms
コード長 2,303 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 94,792 KB
実行使用メモリ 5,664 KB
最終ジャッジ日時 2023-09-27 05:00:15
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
5,312 KB
testcase_01 AC 30 ms
4,420 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 51 ms
5,320 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 28 ms
4,480 KB
testcase_19 AC 24 ms
4,464 KB
testcase_20 AC 57 ms
5,312 KB
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 32 ms
4,624 KB
testcase_24 AC 66 ms
5,476 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 54 ms
5,472 KB
testcase_27 AC 68 ms
5,316 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 55 ms
5,664 KB
testcase_31 AC 53 ms
5,360 KB
testcase_32 AC 34 ms
4,420 KB
testcase_33 AC 63 ms
5,508 KB
testcase_34 AC 55 ms
5,320 KB
testcase_35 AC 23 ms
4,380 KB
testcase_36 AC 9 ms
4,380 KB
testcase_37 AC 31 ms
4,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
typedef pii SegT;
const pii defvalue=pii(0,0);
//const int defvalue=0;
class SegTree{
	private:
		vector<SegT>val;
		int n;
		SegT combine(SegT a,SegT b){
			if(a.first==b.first){
				if(a.second<b.second)return a;
				else return b;
			}
			if(a.first>b.first)return a;
			else return b;
//			return max(a,b);
		}
	public:
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n,defvalue);
		}
		SegTree(const vector<SegT> &in){
			n=1;
			while(n<in.size())n<<=1;
			val=vector<SegT>(2*n,defvalue);
			for(int i=n-1+in.size()-1;i>=0;i--){
				if(n-1<=i)val[i]=in[i-(n-1)];
				else val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
			if(r==-1)r=n;
			if(r<=a||b<=l)return defvalue;
			if(a<=l&&r<=b)return val[k];
			else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
		}
		void tmp(){
//			rep(i,val.size())cout<<" "<<val[i];cout<<endl;
		}
};
int main(){
	int n,d,q;
	cin>>n>>d>>q;
	SegTree st(n);
	vi in(n);
	rep(i,n){
		int a;cin>>a;
		in[i]=a;
		st.update(i,pii(a,i));
	}
	int out=-1;
	int a,b;
	rep(i,n-1){
		pii t=st.query(i+1,i+1+d);
		if(out<t.first-in[i]){
			out=t.first-in[i];
			a=i;
			b=t.second;
		}
	}
	if(out<0)out=0;
	cout<<(ll)out*q<<endl;
	if(out>0){
		cout<<a<<" "<<b<<endl;
	}
}









0