結果

問題 No.489 株に挑戦
ユーザー hanorverhanorver
提出日時 2017-03-01 21:57:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 914 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 11,040 KB
実行使用メモリ 27,556 KB
最終ジャッジ日時 2023-09-03 17:09:34
合計ジャッジ時間 4,902 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 14 ms
8,232 KB
testcase_03 AC 15 ms
8,376 KB
testcase_04 AC 15 ms
8,372 KB
testcase_05 AC 14 ms
8,232 KB
testcase_06 AC 14 ms
8,420 KB
testcase_07 AC 15 ms
8,212 KB
testcase_08 AC 14 ms
8,252 KB
testcase_09 AC 15 ms
8,444 KB
testcase_10 AC 14 ms
8,248 KB
testcase_11 AC 13 ms
8,240 KB
testcase_12 AC 14 ms
8,252 KB
testcase_13 AC 14 ms
8,252 KB
testcase_14 AC 14 ms
8,448 KB
testcase_15 AC 40 ms
8,968 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

INF=-1000000007
SQRT_N = 512
N,D,K = map(int,input().split())
x = [int(input()) for i in range(N)]
b_size = (N + SQRT_N - 1) // SQRT_N
bucket = [(INF,INF) for i in range(b_size * SQRT_N)]
bucketMax = [(INF,INF) for i in range(b_size)]

def query(left,right):
	ret = (INF,INF)
	for i in range(left // SQRT_N, b_size):
		l = i * SQRT_N
		r = (i+1) * SQRT_N
		if right <= l:
			break
		if r <= left or right <= l:
			continue
		if left <= l and r <= right:
			ret = max(ret,bucketMax[i])
		else:
			s,t = max(left,l),min(right,r)
			ret = max(ret, max(bucket[s:t]))

	return ret

for i in range(N):
	bucket[i] = (x[i],-i)
for i in range(N):
	k = i // SQRT_N
	bucketMax[k] = max(bucketMax[k],bucket[i])
ans,pair = 0,()
for i in range(N-1):
	ret = query(i+1,min(N,i+D+1))
	if ans < ret[0]-x[i]:
		ans = ret[0]-x[i]
		pair = (i,-ret[1])
if ans <= 0:
	print(0)
else:
	print(ans*K)
	print(' '.join([str(_) for _ in pair]))
0