結果

問題 No.489 株に挑戦
ユーザー tookunn_1213tookunn_1213
提出日時 2017-03-01 17:45:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,338 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 85,792 KB
実行使用メモリ 84,144 KB
最終ジャッジ日時 2023-09-03 16:35:12
合計ジャッジ時間 27,070 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 847 ms
80,808 KB
testcase_02 AC 77 ms
74,852 KB
testcase_03 AC 77 ms
74,800 KB
testcase_04 AC 79 ms
74,896 KB
testcase_05 AC 78 ms
74,860 KB
testcase_06 AC 79 ms
74,804 KB
testcase_07 AC 84 ms
75,060 KB
testcase_08 AC 80 ms
74,908 KB
testcase_09 AC 84 ms
74,964 KB
testcase_10 AC 81 ms
74,796 KB
testcase_11 AC 84 ms
75,028 KB
testcase_12 AC 83 ms
74,928 KB
testcase_13 AC 82 ms
75,064 KB
testcase_14 AC 87 ms
75,160 KB
testcase_15 AC 183 ms
77,996 KB
testcase_16 TLE -
testcase_17 AC 268 ms
78,376 KB
testcase_18 AC 853 ms
80,984 KB
testcase_19 AC 743 ms
80,476 KB
testcase_20 TLE -
testcase_21 AC 476 ms
79,140 KB
testcase_22 AC 241 ms
77,764 KB
testcase_23 AC 762 ms
80,984 KB
testcase_24 TLE -
testcase_25 AC 84 ms
74,948 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 78 ms
74,892 KB
testcase_29 AC 79 ms
74,828 KB
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 922 ms
81,248 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 638 ms
79,680 KB
testcase_36 AC 322 ms
78,760 KB
testcase_37 AC 925 ms
81,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF=-1000000007
SQRT_N = 1024
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,bucketMax
	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