結果

問題 No.489 株に挑戦
ユーザー tkmst201tkmst201
提出日時 2017-05-22 20:13:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,698 bytes
コンパイル時間 5,843 ms
コンパイル使用メモリ 167,108 KB
実行使用メモリ 5,732 KB
最終ジャッジ日時 2023-10-19 14:13:07
合計ジャッジ時間 3,580 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 35 ms
5,708 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 36 ms
5,708 KB
testcase_21 AC 10 ms
4,348 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 34 ms
5,708 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 37 ms
5,708 KB
testcase_31 AC 39 ms
5,708 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 6 ms
4,348 KB
testcase_37 AC 22 ms
4,652 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         REP(i, N) scanf("%d", x + i);
      |                   ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

struct SegmentTree {
	pii init_val;
	int n;
	vector<pii> dat;
	
	SegmentTree(int _n) {
		init_val = pii(0, 0);
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(2 * n - 1, init_val);
	}
	
	void update(int k, pii a) {
		k += n - 1;
		chmax(dat[k], a);
		
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	
	pii query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return max(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	
	pii query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int N, D, K;
int x[112345];

int main() {
	cin >> N >> D >> K;
	REP(i, N) scanf("%d", x + i);
	
	SegmentTree seg(N);
	REP(i, N) seg.update(i, pii(x[i], -i));
	
	int ans = 0, anspos = 1;
	
	REP(i, N - 1) if ( chmax(ans, seg.query(i + 1, min(N, i + 1 + D)).fi - x[i]) ) anspos = -i;
	
	if (ans == 0) puts("0");
	else {	
		printf("%lld\n", (ll)ans * K);
		printf("%d %d\n", -anspos, -seg.query(anspos, min(N, anspos + 1 + D)).se);
	}
	return 0;
}
0