結果

問題 No.489 株に挑戦
ユーザー こるこる
提出日時 2017-02-25 11:44:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 33 ms / 1,000 ms
コード長 1,834 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 89,440 KB
実行使用メモリ 4,632 KB
最終ジャッジ日時 2023-09-27 05:21:33
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
4,380 KB
testcase_01 AC 16 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 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,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 23 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 14 ms
4,380 KB
testcase_19 AC 11 ms
4,376 KB
testcase_20 AC 28 ms
4,384 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 18 ms
4,380 KB
testcase_24 AC 33 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 29 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 32 ms
4,376 KB
testcase_31 AC 29 ms
4,632 KB
testcase_32 AC 18 ms
4,376 KB
testcase_33 AC 31 ms
4,376 KB
testcase_34 AC 27 ms
4,380 KB
testcase_35 AC 12 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 17 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define VB vector<bool>
#define VPLL vector<pair<ll,ll> >
#define VVL vector<vector<ll> >
#define VVVL vector<vector<vector<ll> > >
#define VVB vector<vector<bool> >
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1000000000000000000
#define PI 3.141592653589793238
#define vmin(vec) *std::min_element(vec.begin(),vec.end())
#define vmax(vec) *std::max_element(vec.begin(),vec.end())
#define vsum(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define ksort(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define ssort(vec) (vec.begin(),vec.end())
#define VPLLsort(vec) sort(vec.begin(), vec.end(),[](PLL &a, PLL &b){ return a.first < b.first; });
#define LTS(n) to_string(n)
#define STL(str) stoll(str)
using namespace std;

int main() {
	ll n, d, k;
	cin >> n >> d >> k;
	VL x(n); rep(i, n) cin >> x[i];
	ll maxi = -1;
	ll mini_index = 0;
	ll maxi_index = 0;
	PLL ans;
	ans.first = 0;
	ans.second = 0;
	deque<ll> dq;
	dq.push_back(0);
	nrep(i, 1, n){
		if (maxi < x[i] - x[dq.front()] && i - dq.front() <= d){
			maxi = x[i] - x[dq.front()];
			ans.second = i;
			ans.first = dq.front();
		}
		if (dq.front()==i-d){
			dq.pop_front();
		}
		while (!dq.empty() && x[dq.back()]>x[i]) dq.pop_back();
		dq.push_back(i);
	}if (maxi <= 0){
		cout << 0 << endl;
	}
	else{
		mrep(i, ans.first){
			if (ans.second - i>d) break;
			if (x[i] == x[ans.first]) ans.first = i;
		}
		cout << maxi*k << endl;
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}
0