結果

問題 No.489 株に挑戦
ユーザー tookunn_1213tookunn_1213
提出日時 2017-03-01 17:41:12
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,337 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 83,584 KB
最終ジャッジ日時 2024-05-10 02:18:57
合計ジャッジ時間 16,950 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 730 ms
82,056 KB
testcase_01 AC 563 ms
79,944 KB
testcase_02 AC 42 ms
57,984 KB
testcase_03 AC 42 ms
57,600 KB
testcase_04 AC 43 ms
58,112 KB
testcase_05 AC 43 ms
58,240 KB
testcase_06 AC 45 ms
59,008 KB
testcase_07 AC 44 ms
59,136 KB
testcase_08 AC 41 ms
58,368 KB
testcase_09 AC 44 ms
60,032 KB
testcase_10 AC 44 ms
58,624 KB
testcase_11 AC 46 ms
60,032 KB
testcase_12 AC 47 ms
59,648 KB
testcase_13 AC 47 ms
60,032 KB
testcase_14 AC 48 ms
59,904 KB
testcase_15 AC 127 ms
77,184 KB
testcase_16 AC 910 ms
82,836 KB
testcase_17 AC 176 ms
77,620 KB
testcase_18 AC 514 ms
80,384 KB
testcase_19 AC 460 ms
79,488 KB
testcase_20 AC 935 ms
82,884 KB
testcase_21 AC 287 ms
78,408 KB
testcase_22 AC 170 ms
77,640 KB
testcase_23 AC 469 ms
80,128 KB
testcase_24 TLE -
testcase_25 AC 49 ms
59,904 KB
testcase_26 AC 978 ms
83,256 KB
testcase_27 TLE -
testcase_28 AC 38 ms
52,480 KB
testcase_29 AC 36 ms
52,608 KB
testcase_30 AC 945 ms
83,480 KB
testcase_31 AC 908 ms
83,040 KB
testcase_32 AC 553 ms
80,280 KB
testcase_33 AC 968 ms
83,260 KB
testcase_34 AC 845 ms
82,468 KB
testcase_35 AC 397 ms
79,300 KB
testcase_36 AC 218 ms
78,376 KB
testcase_37 AC 531 ms
80,640 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 update(index,value):
	global bucket,SQRT_N,buckerMax
	k = index // SQRT_N
	bucket[index] = (index,value)
	ret = bucket[index]
	for i in range(k * SQRT_N,(k+1)*SQRT_N):
		if ret[1] < bucket[i][1]:
			ret = bucket[i]
		elif ret[1] == bucket[i][1] and ret[0] > bucket[i][0]:
			ret = bucket[i]
	bucketMax[k] = ret
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:
			if ret[1] < bucketMax[i][1]:
				ret = bucketMax[i]
			elif ret[1] == bucketMax[i][1] and ret[0] > bucketMax[i][0]:
				ret = bucketMax[i]
		else:
			for j in range(max(left,l),min(right,r)):
				if ret[1] < bucket[j][1]:
					ret = bucket[j]
				elif ret[1] == bucket[j][1] and ret[0] > bucket[j][0]:
					ret = bucket[j]
	return ret
for i in range(N):
	update(i,x[i])
ans = 0
pair = [INF,INF]
for i in range(N-1):
	ret = query(i+1,min(N,i+D+1))
	if ans < ret[1]-x[i]:
		ans = ret[1]-x[i]
		pair = [i,ret[0]]
if ans <= 0:
	print(0)
else:
	print(ans*K)
	print(' '.join([str(_) for _ in pair]))
0