結果

問題 No.489 株に挑戦
ユーザー tookunn_1213tookunn_1213
提出日時 2017-03-01 19:10:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 466 ms / 1,000 ms
コード長 904 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 82,592 KB
最終ジャッジ日時 2023-09-27 05:34:06
合計ジャッジ時間 9,508 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
80,992 KB
testcase_01 AC 253 ms
80,376 KB
testcase_02 AC 62 ms
71,272 KB
testcase_03 AC 61 ms
71,384 KB
testcase_04 AC 62 ms
71,416 KB
testcase_05 AC 63 ms
71,272 KB
testcase_06 AC 64 ms
71,416 KB
testcase_07 AC 67 ms
75,268 KB
testcase_08 AC 63 ms
71,300 KB
testcase_09 AC 69 ms
75,548 KB
testcase_10 AC 63 ms
71,308 KB
testcase_11 AC 66 ms
75,440 KB
testcase_12 AC 68 ms
75,360 KB
testcase_13 AC 68 ms
75,384 KB
testcase_14 AC 67 ms
75,700 KB
testcase_15 AC 103 ms
78,052 KB
testcase_16 AC 424 ms
81,812 KB
testcase_17 AC 113 ms
78,388 KB
testcase_18 AC 240 ms
80,044 KB
testcase_19 AC 235 ms
79,700 KB
testcase_20 AC 425 ms
81,980 KB
testcase_21 AC 169 ms
79,248 KB
testcase_22 AC 126 ms
78,088 KB
testcase_23 AC 167 ms
79,972 KB
testcase_24 AC 466 ms
82,592 KB
testcase_25 AC 67 ms
75,256 KB
testcase_26 AC 415 ms
82,056 KB
testcase_27 AC 436 ms
81,872 KB
testcase_28 AC 65 ms
71,480 KB
testcase_29 AC 65 ms
71,316 KB
testcase_30 AC 398 ms
82,292 KB
testcase_31 AC 401 ms
81,872 KB
testcase_32 AC 247 ms
80,368 KB
testcase_33 AC 417 ms
82,208 KB
testcase_34 AC 362 ms
81,400 KB
testcase_35 AC 203 ms
79,308 KB
testcase_36 AC 142 ms
79,272 KB
testcase_37 AC 238 ms
80,988 KB
権限があれば一括ダウンロードができます

ソースコード

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):
	global b_size
	ret = (INF,INF)
	for i in range(b_size):
		l = i * SQRT_N
		r = (i+1) * SQRT_N
		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)
			while s < t:
				ret = max(ret,bucket[s])
				s+=1
	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