結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 326 ms
81,116 KB
testcase_01 AC 275 ms
80,172 KB
testcase_02 AC 72 ms
71,296 KB
testcase_03 AC 70 ms
71,360 KB
testcase_04 AC 73 ms
71,540 KB
testcase_05 AC 72 ms
71,524 KB
testcase_06 AC 73 ms
71,384 KB
testcase_07 AC 75 ms
75,340 KB
testcase_08 AC 69 ms
71,480 KB
testcase_09 AC 74 ms
75,444 KB
testcase_10 AC 72 ms
71,472 KB
testcase_11 AC 76 ms
75,252 KB
testcase_12 AC 81 ms
75,676 KB
testcase_13 AC 78 ms
75,588 KB
testcase_14 AC 76 ms
75,572 KB
testcase_15 AC 119 ms
78,400 KB
testcase_16 AC 456 ms
81,980 KB
testcase_17 AC 122 ms
78,480 KB
testcase_18 AC 272 ms
80,148 KB
testcase_19 AC 261 ms
79,924 KB
testcase_20 AC 463 ms
82,020 KB
testcase_21 AC 191 ms
79,300 KB
testcase_22 AC 145 ms
78,300 KB
testcase_23 AC 193 ms
80,192 KB
testcase_24 AC 512 ms
82,728 KB
testcase_25 AC 77 ms
75,552 KB
testcase_26 AC 445 ms
81,876 KB
testcase_27 AC 453 ms
82,144 KB
testcase_28 AC 73 ms
71,644 KB
testcase_29 AC 72 ms
71,420 KB
testcase_30 AC 423 ms
82,256 KB
testcase_31 AC 436 ms
81,636 KB
testcase_32 AC 265 ms
80,364 KB
testcase_33 AC 449 ms
82,232 KB
testcase_34 AC 391 ms
81,556 KB
testcase_35 AC 227 ms
79,484 KB
testcase_36 AC 161 ms
79,460 KB
testcase_37 AC 264 ms
81,048 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