結果

問題 No.489 株に挑戦
ユーザー DAyamaCTFDAyamaCTF
提出日時 2017-02-24 23:27:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,011 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 174,216 KB
実行使用メモリ 5,484 KB
最終ジャッジ日時 2023-08-31 00:03:36
合計ジャッジ時間 4,240 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 29 ms
5,164 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 20 ms
4,400 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 24 ms
5,212 KB
testcase_27 AC 41 ms
5,160 KB
testcase_28 WA -
testcase_29 AC 1 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3
#define MAX_N (1<<18)

struct RangeMinQuery{
	int idx[2*MAX_N-1];
	int dat[MAX_N];
	int size;

	void update(int k){
		k+=size-1;
		idx[k]=k-(size-1);
		while(k>0){
			k=(k-1)/2;
			if(idx[k*2+1]!=-1&&idx[k*2+2]!=-1){
				if(dat[idx[k*2+1]]<dat[idx[k*2+2]])idx[k]=idx[k*2+1];
				else idx[k]=idx[k*2+2];
			}else{
				idx[k]=max(idx[k*2+1],idx[k*2+2]);
			}
		}
	}

	void init(int *a,int n_){
		size=1;
		while(size<n_) size*=2;
		for(int i=0;i<2*size-1;i++)idx[i]=-1;
		for(int i=0;i<n_;i++)dat[i]=a[i];
		for(int i=0;i<n_;i++)update(i);
	}

	int subquery(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return -1;
		if(a<=l&&r<=b)return idx[k];
		else{
			int ldx=subquery(a,b,k*2+1,l,(l+r)/2),rdx=subquery(a,b,k*2+2,(l+r)/2,r);
			if(ldx!=-1&&rdx!=-1){
				if(dat[ldx]<=dat[rdx])return ldx;
				else return rdx;
			}else{
				return max(ldx,rdx);
			}
		}
	}

	int query(int a,int b){
		return subquery(a,b,0,0,size);
	}
};

int n,d,K;
int a[111111];
int deq[111111];
RangeMinQuery s;

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>d>>K;
	rep(i,n){
		cin>>a[i];
		a[i]=-a[i];
	}
	s.init(a,n);
	int res=0;
	int j,k;
	rep(i,n-d){
		int idx=s.query(i+1,i+d+1);
		if(idx>=0&&res<-a[idx]+a[i]){
			res=-a[idx]+a[i];
			j=i;
			k=idx;
		}
	}
	cout<<res*K<<endl;
	if(res>0)cout<<j<<" "<<k<<endl;
	return 0;
}
0