結果

問題 No.489 株に挑戦
ユーザー 25__toma25__toma
提出日時 2018-10-09 23:58:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 1,000 ms
コード長 1,426 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 103,808 KB
実行使用メモリ 6,172 KB
最終ジャッジ日時 2023-09-27 06:00:08
合計ジャッジ時間 2,967 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
5,836 KB
testcase_01 AC 18 ms
4,432 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 27 ms
5,912 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 15 ms
4,720 KB
testcase_19 AC 13 ms
4,380 KB
testcase_20 AC 31 ms
5,916 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 20 ms
4,424 KB
testcase_24 AC 36 ms
5,960 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 33 ms
6,172 KB
testcase_27 AC 37 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 36 ms
6,028 KB
testcase_31 AC 31 ms
5,836 KB
testcase_32 AC 20 ms
4,424 KB
testcase_33 AC 34 ms
5,928 KB
testcase_34 AC 30 ms
5,708 KB
testcase_35 AC 13 ms
4,380 KB
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 20 ms
4,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



//ϐ
ll N, D, K;
vector<ll> x;

//vZ
void calc()
{
	cin >> N >> D >> K;
	x.resize(N);
	REP(i, N) cin >> x[i];

	pair<ll, ll> res;
	ll best = -INF;
	using pll = pair<ll, ll>;
	using pqp = priority_queue<pll, vector<pll>, greater<pll>>;
	pqp pq;
	pq.push({ x[0],0 });

	FOR(i, 1, N) {
		while (pq.top().second < i - D)pq.pop();
		auto benefit = x[i] - pq.top().first;
		if (benefit > best) {
			best = benefit;
			res = { pq.top().second,i };
		}
		pq.push({ x[i],i });
	}
	if (best <= 0)cout << 0 << endl;
	else {
		cout << best * K << endl;
		cout << res.first << " " << res.second << endl;
	}
}
//fobO
void debug()
{
	int N;
	cin>>N;
}


//C֐
int main()
{
	calc();
	debug();
	
	return 0;
}
0