結果

問題 No.489 株に挑戦
ユーザー brthyyjpbrthyyjp
提出日時 2020-09-08 02:14:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,627 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 83,104 KB
最終ジャッジ日時 2023-08-19 17:27:49
合計ジャッジ時間 8,031 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
82,332 KB
testcase_01 AC 167 ms
80,424 KB
testcase_02 AC 73 ms
71,308 KB
testcase_03 AC 71 ms
71,160 KB
testcase_04 AC 73 ms
71,272 KB
testcase_05 AC 74 ms
71,364 KB
testcase_06 AC 74 ms
71,000 KB
testcase_07 AC 74 ms
71,476 KB
testcase_08 AC 73 ms
71,132 KB
testcase_09 AC 75 ms
71,236 KB
testcase_10 AC 74 ms
71,308 KB
testcase_11 AC 76 ms
71,104 KB
testcase_12 AC 74 ms
71,140 KB
testcase_13 AC 74 ms
71,160 KB
testcase_14 AC 74 ms
71,240 KB
testcase_15 AC 118 ms
77,948 KB
testcase_16 AC 211 ms
82,880 KB
testcase_17 AC 113 ms
78,012 KB
testcase_18 WA -
testcase_19 AC 156 ms
80,028 KB
testcase_20 AC 188 ms
82,252 KB
testcase_21 AC 152 ms
79,072 KB
testcase_22 AC 118 ms
77,892 KB
testcase_23 AC 148 ms
80,132 KB
testcase_24 AC 199 ms
83,104 KB
testcase_25 AC 76 ms
71,152 KB
testcase_26 AC 172 ms
82,608 KB
testcase_27 AC 176 ms
82,888 KB
testcase_28 AC 73 ms
71,320 KB
testcase_29 AC 73 ms
71,140 KB
testcase_30 AC 183 ms
82,528 KB
testcase_31 AC 158 ms
82,336 KB
testcase_32 AC 165 ms
80,192 KB
testcase_33 AC 197 ms
82,888 KB
testcase_34 AC 189 ms
82,220 KB
testcase_35 AC 161 ms
79,860 KB
testcase_36 AC 129 ms
78,156 KB
testcase_37 AC 165 ms
80,748 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