結果

問題 No.489 株に挑戦
ユーザー brthyyjpbrthyyjp
提出日時 2020-09-08 02:14:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,627 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 82,264 KB
最終ジャッジ日時 2024-05-07 00:28:03
合計ジャッジ時間 5,648 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
81,052 KB
testcase_01 AC 132 ms
79,412 KB
testcase_02 AC 36 ms
52,412 KB
testcase_03 AC 36 ms
53,080 KB
testcase_04 AC 37 ms
53,484 KB
testcase_05 AC 36 ms
52,868 KB
testcase_06 AC 40 ms
53,564 KB
testcase_07 AC 38 ms
52,884 KB
testcase_08 AC 35 ms
53,984 KB
testcase_09 AC 37 ms
53,264 KB
testcase_10 AC 36 ms
53,620 KB
testcase_11 AC 37 ms
52,596 KB
testcase_12 AC 37 ms
54,224 KB
testcase_13 AC 37 ms
52,900 KB
testcase_14 AC 37 ms
54,600 KB
testcase_15 AC 80 ms
76,672 KB
testcase_16 AC 166 ms
81,500 KB
testcase_17 AC 73 ms
77,236 KB
testcase_18 WA -
testcase_19 AC 115 ms
79,288 KB
testcase_20 AC 144 ms
81,836 KB
testcase_21 AC 109 ms
78,164 KB
testcase_22 AC 80 ms
77,320 KB
testcase_23 AC 108 ms
79,504 KB
testcase_24 AC 154 ms
82,156 KB
testcase_25 AC 35 ms
53,764 KB
testcase_26 AC 128 ms
82,264 KB
testcase_27 AC 131 ms
81,988 KB
testcase_28 AC 35 ms
53,696 KB
testcase_29 AC 35 ms
52,648 KB
testcase_30 AC 138 ms
82,220 KB
testcase_31 AC 118 ms
81,572 KB
testcase_32 AC 125 ms
79,424 KB
testcase_33 AC 155 ms
81,764 KB
testcase_34 AC 150 ms
82,116 KB
testcase_35 AC 115 ms
78,800 KB
testcase_36 AC 93 ms
77,032 KB
testcase_37 AC 129 ms
79,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n, d, k = map(int, input().split())
X = [(int(input()), i) for i in range(n)]

class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num = 2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.segfunc = segfunc
        self.seg = [ide_ele]*2*self.num
        # set_val
        for i in range(self.n):
            self.seg[i+self.num] = init_val[i]
        # built
        for i in range(self.num-1, 0, -1):
            self.seg[i] = self.segfunc(self.seg[2*i], self.seg[2*i+1])

    def update(self, k, x):
        k += self.num
        self.seg[k] = x
        while k:
            k = k >> 1
            self.seg[k] = self.segfunc(self.seg[2*k], self.seg[2*k+1])

    def query(self, l, r):
        if r <= l:
            return self.ide_ele
        l += self.num
        r += self.num
        res = self.ide_ele
        while l < r:
            if r & 1:
                r -= 1
                res = self.segfunc(res, self.seg[r])
            if l & 1:
                res = self.segfunc(res, self.seg[l])
                l += 1
            l = l >> 1
            r = r >> 1
        return res

def segfunc(x, y):
    if x[0] >= y[0]:
        return x
    else:
        return y

seg = SegTree(X, (0, -1), segfunc)

M = 0
for l in range(n):
    r = min(l+d, n-1)
    s, t = seg.query(l, r+1)
    temp = k*(s-X[l][0])
    if temp > M:
        M = temp
        ans = (l, t)
if M != 0:
    print(M)
    print(*ans)
else:
    print(M)
0