結果

問題 No.489 株に挑戦
ユーザー tatsukawatatsukawa
提出日時 2017-02-25 19:42:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,143 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 172,252 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2023-09-02 08:07:26
合計ジャッジ時間 4,087 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,376 KB
testcase_01 AC 33 ms
5,488 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 62 ms
6,440 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 22 ms
4,376 KB
testcase_19 AC 23 ms
4,752 KB
testcase_20 AC 69 ms
6,492 KB
testcase_21 AC 14 ms
4,620 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 17 ms
4,376 KB
testcase_24 AC 75 ms
6,428 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 45 ms
9,332 KB
testcase_27 AC 24 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 91 ms
10,132 KB
testcase_31 AC 45 ms
10,188 KB
testcase_32 AC 23 ms
4,380 KB
testcase_33 AC 70 ms
6,340 KB
testcase_34 AC 44 ms
4,376 KB
testcase_35 AC 18 ms
4,376 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 36 ms
6,020 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];
	}

	if(D == 1) {
		cout << 0 << endl;
		return 0;
	}

	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