結果

問題 No.489 株に挑戦
ユーザー hanorverhanorver
提出日時 2017-03-01 20:43:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 463 ms / 1,000 ms
コード長 904 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 82,604 KB
最終ジャッジ日時 2023-09-27 05:37:05
合計ジャッジ時間 9,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
80,948 KB
testcase_01 AC 246 ms
79,980 KB
testcase_02 AC 65 ms
71,264 KB
testcase_03 AC 65 ms
71,300 KB
testcase_04 AC 64 ms
71,316 KB
testcase_05 AC 63 ms
71,164 KB
testcase_06 AC 65 ms
71,600 KB
testcase_07 AC 68 ms
75,560 KB
testcase_08 AC 63 ms
71,592 KB
testcase_09 AC 68 ms
75,380 KB
testcase_10 AC 64 ms
71,588 KB
testcase_11 AC 68 ms
75,464 KB
testcase_12 AC 68 ms
75,348 KB
testcase_13 AC 67 ms
75,432 KB
testcase_14 AC 69 ms
75,584 KB
testcase_15 AC 105 ms
78,088 KB
testcase_16 AC 424 ms
81,696 KB
testcase_17 AC 111 ms
78,600 KB
testcase_18 AC 244 ms
80,220 KB
testcase_19 AC 234 ms
79,924 KB
testcase_20 AC 421 ms
81,856 KB
testcase_21 AC 171 ms
79,236 KB
testcase_22 AC 130 ms
78,300 KB
testcase_23 AC 172 ms
80,248 KB
testcase_24 AC 463 ms
82,604 KB
testcase_25 AC 68 ms
75,460 KB
testcase_26 AC 414 ms
81,792 KB
testcase_27 AC 428 ms
81,916 KB
testcase_28 AC 64 ms
71,324 KB
testcase_29 AC 63 ms
71,288 KB
testcase_30 AC 401 ms
82,408 KB
testcase_31 AC 396 ms
81,764 KB
testcase_32 AC 253 ms
80,296 KB
testcase_33 AC 425 ms
82,176 KB
testcase_34 AC 367 ms
81,316 KB
testcase_35 AC 213 ms
79,352 KB
testcase_36 AC 148 ms
79,436 KB
testcase_37 AC 242 ms
80,692 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