結果

問題 No.489 株に挑戦
ユーザー tkmst201tkmst201
提出日時 2017-05-22 20:24:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 45 ms / 1,000 ms
コード長 1,700 bytes
コンパイル時間 1,291 ms
コンパイル使用メモリ 154,384 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2023-09-27 05:46:31
合計ジャッジ時間 3,532 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
5,760 KB
testcase_01 AC 21 ms
4,728 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 36 ms
5,612 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 22 ms
4,464 KB
testcase_19 AC 16 ms
4,376 KB
testcase_20 AC 39 ms
5,420 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 23 ms
4,488 KB
testcase_24 AC 44 ms
5,448 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 36 ms
5,484 KB
testcase_27 AC 45 ms
5,420 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 39 ms
5,508 KB
testcase_31 AC 42 ms
5,604 KB
testcase_32 AC 24 ms
4,456 KB
testcase_33 AC 42 ms
5,480 KB
testcase_34 AC 38 ms
5,608 KB
testcase_35 AC 15 ms
4,376 KB
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 22 ms
4,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

struct SegmentTree {
	pii init_val;
	int n;
	vector<pii> dat;
	
	SegmentTree(int _n) {
		init_val = pii(0, 0);
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(2 * n - 1, init_val);
	}
	
	void update(int k, pii a) {
		k += n - 1;
		chmax(dat[k], a);
		
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	
	pii query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return max(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	
	pii query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int N, D, K;
int x[112345];

int main() {
	cin >> N >> D >> K;
	REP(i, N) scanf("%d", x + i);
	
	SegmentTree seg(N);
	REP(i, N) seg.update(i, pii(x[i], -i));
	
	int ans = 0;
	pii anspos;
	
	REP(i, N - 1) {
		pii now = seg.query(i + 1, min(N, i + 1 + D));
		if (chmax(ans, now.fi - x[i])) anspos = pii(i, -now.se);
	}
	
	if (ans == 0) puts("0");
	else {	
		printf("%lld\n", (ll)ans * K);
		printf("%d %d\n", anspos.fi, anspos.se);
	}
	return 0;
}
0