結果

問題 No.489 株に挑戦
ユーザー kotamanegikotamanegi
提出日時 2017-02-24 22:58:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 1,680 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 85,804 KB
実行使用メモリ 7,152 KB
最終ジャッジ日時 2023-09-27 05:03:51
合計ジャッジ時間 3,079 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
6,548 KB
testcase_01 AC 30 ms
6,204 KB
testcase_02 AC 2 ms
5,708 KB
testcase_03 AC 2 ms
5,600 KB
testcase_04 AC 2 ms
5,680 KB
testcase_05 AC 2 ms
5,544 KB
testcase_06 AC 2 ms
5,400 KB
testcase_07 AC 2 ms
5,464 KB
testcase_08 AC 2 ms
5,460 KB
testcase_09 AC 2 ms
5,460 KB
testcase_10 AC 2 ms
5,488 KB
testcase_11 AC 2 ms
5,408 KB
testcase_12 AC 2 ms
5,460 KB
testcase_13 AC 2 ms
5,380 KB
testcase_14 AC 2 ms
5,456 KB
testcase_15 AC 4 ms
5,508 KB
testcase_16 AC 46 ms
6,668 KB
testcase_17 AC 7 ms
5,664 KB
testcase_18 AC 26 ms
6,400 KB
testcase_19 AC 22 ms
6,024 KB
testcase_20 AC 52 ms
6,800 KB
testcase_21 AC 14 ms
5,740 KB
testcase_22 AC 6 ms
5,524 KB
testcase_23 AC 28 ms
6,232 KB
testcase_24 AC 58 ms
6,908 KB
testcase_25 AC 2 ms
5,368 KB
testcase_26 AC 51 ms
6,952 KB
testcase_27 AC 54 ms
7,000 KB
testcase_28 AC 2 ms
5,484 KB
testcase_29 AC 2 ms
5,460 KB
testcase_30 AC 52 ms
7,152 KB
testcase_31 AC 50 ms
7,068 KB
testcase_32 AC 32 ms
6,276 KB
testcase_33 AC 56 ms
6,996 KB
testcase_34 AC 49 ms
6,884 KB
testcase_35 AC 21 ms
5,976 KB
testcase_36 AC 10 ms
5,624 KB
testcase_37 AC 32 ms
6,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
long long x[600000] = {};
long long seg[600000] = {};
long long setter(long long now) {
	seg[now] = max(seg[now * 2], seg[now * 2 + 1]);
	if (now != 1) {
		long long wow = setter(now / 2);
	}
	return 0;
}
long long find(long long now, long long n_l,long long n_r,long long w_l,long long w_r) {
	if (n_r - 1 <= w_l || w_r < n_l) return -1;
	if (w_l <= n_l&&n_r-1 <= w_r) return seg[now];
	long long aaa = find(now*2,n_l,(n_l+n_r)/2,w_l,w_r);
	aaa = max(aaa,find(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r));
	return aaa;
}
#define nya 131072
int main() {
	long long n, d, k;
	cin >> n >> d >> k;
	REP(i, n) {
		cin >> x[i];
		seg[nya+i] = x[i];
		setter((nya+i)/2);
	}
	long long hoge = 0;
	long long left = -1;
	for (int i = 0;i < n;++i) {
		long long maxium = find(1, 0, nya + 1, i, i + d);
		if (hoge < (maxium - x[i])) {
			hoge = maxium - x[i];
			left = i;
		}
	}
	if (left == -1) {
		cout << 0 << endl;
		return 0;
	}
	cout << hoge*k << endl;
	cout << left << " ";
	long long max_now = 0;
	long long max_right = 0;
	for (int q = 0;q <= d;++q) {
		if (max_now < x[q + left]) {
			max_now = x[q + left];
			max_right = q + left;
		}
	}
	cout << max_right << endl;
	return 0;
}
0