結果

問題 No.489 株に挑戦
ユーザー tatsukawatatsukawa
提出日時 2017-02-25 19:44:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 73 ms / 1,000 ms
コード長 1,091 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 150,164 KB
実行使用メモリ 10,260 KB
最終ジャッジ日時 2023-09-27 05:20:04
合計ジャッジ時間 3,241 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,376 KB
testcase_01 AC 30 ms
5,404 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 52 ms
6,136 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 22 ms
4,656 KB
testcase_20 AC 56 ms
6,780 KB
testcase_21 AC 12 ms
4,464 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 61 ms
6,732 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 42 ms
9,316 KB
testcase_27 AC 22 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 73 ms
10,224 KB
testcase_31 AC 43 ms
10,260 KB
testcase_32 AC 22 ms
4,380 KB
testcase_33 AC 59 ms
6,160 KB
testcase_34 AC 41 ms
4,420 KB
testcase_35 AC 17 ms
4,376 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 33 ms
6,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)

using namespace std;
using ll = int64_t;

struct compare {
	bool operator() (const pair<ll, int> &l, const pair<ll, int>& r) const {
		if(l.first > r.first) {
			return l.second > r.second;
		} else {
			return false;
		}
	}
};

int main() {
    ios::sync_with_stdio(false);

	int j, k;
	ll N, D, K, ans = 0;
	cin >> N >> D >> K;

	multiset<pair<ll,int>, compare> a;
	vector<ll> x(N);

	for(int i = 0; i < N; i++) {
		cin >> x[i];
	}

	for(int i = 0; i < D; i++) {
		a.insert({x[i],i});
	}

	for(int i = 0; i < N; i++) {

		if(i+D < N) {
			a.insert({x[i+D], i+D});
		}
		auto it = a.lower_bound({x[i], i});
		a.erase(it);

		pair<ll, int> l = {x[i], i};

		if(a.size() == 0) break;;
		auto r = *(a.begin());
		int y = -l.first + r.first;

		if (y > ans)
		{
		    ans = y;
		    j = l.second;
		    k = r.second;
		}
	}

	cout << ans * K << endl;
	if (ans == 0)
	    return 0;
	cout << j << ' ' << k << endl;
}
0