結果

問題 No.489 株に挑戦
ユーザー mbanmban
提出日時 2017-05-09 21:23:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,039 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 8,700 KB
最終ジャッジ日時 2023-10-12 21:51:46
合計ジャッジ時間 3,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<math.h>

using namespace std;


int main() {
	int N, D, K;
	int T = 1000;
	cin >> N >> D >> K;
	T = (int)sqrt(N);
	int X[100000], Table[1000], Index[1000];
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		if (Table[i / T] < X[i]) {
			Table[i / T] = X[i];
			Index[i / T] = i;
		}
	}

	int ans = 0;
	int ansL = -1, ansR = -1;

	for (int i = 0; i < N - 1; i++) {
		int right = min(i + D, N - 1);
		int max = 0;
		int r = -1;
		for (int j = i + 1; j <= right && j % T <= T - 1; j++) {
			if (max < X[j]) {
				max = X[j];
				r = j;
			}
		}

		for (int j = i / T + 1; j < right / T; j++) {
			if (max < Table[j]) {
				max = Table[j];
				r = Index[j];
			}
		}

		for (int j = right; j >= i && j % T != T - 1; j--) {
			if (max <= X[j]) {
				max = X[j];
				r = j;
			}
		}

		if (ans < max - X[i]) {
			ans = max - X[i];
			ansL = i;
			ansR = r;
		}
	}

	cout << (long long)ans*K << endl;
	if (ans == 0)return 0;
	cout << ansL << " " << ansR << endl;
}



0