結果

問題 No.489 株に挑戦
ユーザー 0w10w1
提出日時 2017-04-10 19:51:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 877 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 130,904 KB
最終ジャッジ日時 2023-09-25 06:52:29
合計ジャッジ時間 21,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 994 ms
116,148 KB
testcase_01 AC 626 ms
103,012 KB
testcase_02 AC 69 ms
70,932 KB
testcase_03 AC 68 ms
71,328 KB
testcase_04 AC 68 ms
71,172 KB
testcase_05 AC 69 ms
71,228 KB
testcase_06 AC 70 ms
71,264 KB
testcase_07 AC 72 ms
71,360 KB
testcase_08 AC 70 ms
71,200 KB
testcase_09 AC 71 ms
71,364 KB
testcase_10 AC 71 ms
70,972 KB
testcase_11 AC 75 ms
75,356 KB
testcase_12 AC 71 ms
71,204 KB
testcase_13 AC 72 ms
71,212 KB
testcase_14 AC 74 ms
75,080 KB
testcase_15 AC 213 ms
81,904 KB
testcase_16 TLE -
testcase_17 AC 311 ms
85,852 KB
testcase_18 AC 762 ms
103,960 KB
testcase_19 AC 559 ms
98,972 KB
testcase_20 TLE -
testcase_21 AC 349 ms
88,900 KB
testcase_22 AC 298 ms
84,896 KB
testcase_23 AC 657 ms
105,880 KB
testcase_24 TLE -
testcase_25 AC 73 ms
75,488 KB
testcase_26 AC 843 ms
127,204 KB
testcase_27 TLE -
testcase_28 AC 67 ms
71,228 KB
testcase_29 AC 68 ms
71,268 KB
testcase_30 AC 981 ms
128,796 KB
testcase_31 AC 768 ms
127,292 KB
testcase_32 AC 861 ms
106,188 KB
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 557 ms
98,152 KB
testcase_36 AC 305 ms
85,604 KB
testcase_37 AC 647 ms
106,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, D, K = map( int, input().split() )
X = list( int( input() ) for i in range( N ) )

def build( maxv, t, lb, rb ):
  if lb + 1 == rb:
    maxv[ t ] = [ X[ lb ], - lb ]
    return
  mid = lb + rb >> 1
  build( maxv, t << 1, lb, mid )
  build( maxv, t << 1 | 1, mid, rb )
  maxv[ t ] = max( maxv[ t << 1 ], maxv[ t << 1 | 1 ] )

maxv = [ [ 0, 0 ] for i in range( N << 2 ) ]
build( maxv, 1, 0, N )

def query( t, lb, rb, ql, qr ):
  if qr <= lb or rb <= ql:
    return [ -1, -1 ]
  if ql <= lb and rb <= qr:
    return maxv[ t ]
  mid = lb + rb >> 1
  return max( query( t << 1, lb, mid, ql, qr ), query( t << 1 | 1, mid, rb, ql, qr ) )

best = 0
bl, br = -1, -1
for i in range( N - 1 ):
  mx = query( 1, 0, N, i + 1, min( N, i + D + 1 ) )
  if best >= mx[ 0 ] - X[ i ]: continue
  best = mx[ 0 ] - X[ i ]
  bl, br = i, -mx[ 1 ]

print( best * K )
if bl != -1:
  print( bl, br )
0