結果

問題 No.489 株に挑戦
ユーザー pekempeypekempey
提出日時 2017-02-27 20:57:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 213 ms / 1,000 ms
コード長 896 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 89,480 KB
最終ジャッジ日時 2023-09-27 05:31:32
合計ジャッジ時間 6,810 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 183 ms
83,876 KB
testcase_01 AC 171 ms
88,124 KB
testcase_02 AC 73 ms
78,444 KB
testcase_03 AC 73 ms
78,212 KB
testcase_04 AC 75 ms
78,384 KB
testcase_05 AC 74 ms
78,184 KB
testcase_06 AC 74 ms
78,244 KB
testcase_07 AC 75 ms
78,456 KB
testcase_08 AC 75 ms
78,284 KB
testcase_09 AC 76 ms
78,256 KB
testcase_10 AC 77 ms
78,364 KB
testcase_11 AC 76 ms
78,456 KB
testcase_12 AC 76 ms
78,188 KB
testcase_13 AC 73 ms
78,320 KB
testcase_14 AC 75 ms
78,240 KB
testcase_15 AC 133 ms
86,496 KB
testcase_16 AC 204 ms
87,124 KB
testcase_17 AC 119 ms
84,148 KB
testcase_18 AC 179 ms
87,660 KB
testcase_19 AC 173 ms
86,244 KB
testcase_20 AC 194 ms
86,748 KB
testcase_21 AC 152 ms
84,368 KB
testcase_22 AC 135 ms
86,700 KB
testcase_23 AC 162 ms
88,060 KB
testcase_24 AC 202 ms
89,480 KB
testcase_25 AC 76 ms
78,092 KB
testcase_26 AC 189 ms
89,424 KB
testcase_27 AC 195 ms
89,452 KB
testcase_28 AC 72 ms
78,440 KB
testcase_29 AC 71 ms
78,268 KB
testcase_30 AC 173 ms
88,668 KB
testcase_31 AC 163 ms
88,956 KB
testcase_32 AC 174 ms
88,088 KB
testcase_33 AC 213 ms
89,212 KB
testcase_34 AC 192 ms
86,128 KB
testcase_35 AC 155 ms
84,260 KB
testcase_36 AC 145 ms
84,556 KB
testcase_37 AC 180 ms
88,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 1 << 17
INF = 10 ** 9
n, d, K = map(int, input().split())
x = [int(input()) for _ in range(n)]

dat = [(INF, INF) for _ in range(N * 2)]

def seg_update(k, v):
    global dat
    k += N
    dat[k] = (k, v)
    while k > 1:
        dat[k >> 1] = min(dat[k], dat[k ^ 1])
        k >>= 1

def seg_query(l, r):
    l += N
    r += N
    mn = (INF, INF)
    while l < r:
        if l & 1:
            mn = min(mn, dat[l])
            l += 1
        if r & 1:
            mn = min(mn, dat[r - 1])
        l >>= 1
        r >>= 1
    return mn        

for i in range(n):
    dat[i + N] = (x[i], i)

for i in reversed(range(1, N)):
    dat[i] = min(dat[i * 2], dat[i * 2 + 1])

opt = (0, 0, 0)
for i in range(1, n):
    j = max(0, i - d)
    val = seg_query(j, i)
    opt = max(opt, (x[i] - val[0], -val[1], -i))

if opt[0] == 0:
    print(0)
else:
    print(opt[0] * K)
    print(-opt[1], -opt[2])
0