結果

問題 No.409 ダイエット
ユーザー mkawa2mkawa2
提出日時 2023-02-06 23:49:09
言語 PyPy3
(7.3.13)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,792 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 120,992 KB
最終ジャッジ日時 2023-09-18 09:22:31
合計ジャッジ時間 23,653 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,520 KB
testcase_01 AC 99 ms
71,712 KB
testcase_02 AC 99 ms
71,660 KB
testcase_03 AC 100 ms
71,580 KB
testcase_04 AC 100 ms
71,668 KB
testcase_05 AC 100 ms
71,484 KB
testcase_06 AC 101 ms
71,524 KB
testcase_07 AC 101 ms
71,292 KB
testcase_08 AC 99 ms
71,716 KB
testcase_09 AC 100 ms
71,488 KB
testcase_10 AC 98 ms
71,656 KB
testcase_11 AC 98 ms
71,564 KB
testcase_12 AC 97 ms
71,424 KB
testcase_13 AC 98 ms
71,756 KB
testcase_14 AC 100 ms
71,484 KB
testcase_15 AC 98 ms
71,564 KB
testcase_16 AC 98 ms
71,484 KB
testcase_17 AC 99 ms
71,440 KB
testcase_18 AC 99 ms
71,288 KB
testcase_19 AC 99 ms
71,636 KB
testcase_20 AC 99 ms
71,600 KB
testcase_21 AC 98 ms
71,512 KB
testcase_22 AC 96 ms
71,796 KB
testcase_23 AC 98 ms
71,516 KB
testcase_24 AC 98 ms
71,420 KB
testcase_25 AC 99 ms
71,768 KB
testcase_26 AC 97 ms
71,616 KB
testcase_27 AC 101 ms
71,420 KB
testcase_28 AC 98 ms
71,316 KB
testcase_29 AC 99 ms
71,716 KB
testcase_30 AC 97 ms
71,812 KB
testcase_31 AC 95 ms
71,820 KB
testcase_32 AC 97 ms
71,760 KB
testcase_33 AC 98 ms
71,488 KB
testcase_34 AC 99 ms
71,620 KB
testcase_35 AC 132 ms
77,736 KB
testcase_36 AC 134 ms
77,736 KB
testcase_37 RE -
testcase_38 AC 128 ms
78,004 KB
testcase_39 AC 134 ms
78,696 KB
testcase_40 AC 134 ms
78,608 KB
testcase_41 AC 125 ms
78,040 KB
testcase_42 AC 134 ms
78,728 KB
testcase_43 AC 131 ms
77,836 KB
testcase_44 RE -
testcase_45 AC 134 ms
78,184 KB
testcase_46 AC 138 ms
78,724 KB
testcase_47 AC 133 ms
77,876 KB
testcase_48 AC 136 ms
78,192 KB
testcase_49 AC 124 ms
78,004 KB
testcase_50 AC 131 ms
78,700 KB
testcase_51 RE -
testcase_52 AC 128 ms
78,032 KB
testcase_53 AC 133 ms
78,028 KB
testcase_54 AC 130 ms
77,996 KB
testcase_55 RE -
testcase_56 AC 165 ms
118,472 KB
testcase_57 AC 264 ms
119,248 KB
testcase_58 AC 205 ms
94,308 KB
testcase_59 AC 242 ms
103,228 KB
testcase_60 AC 201 ms
92,736 KB
testcase_61 AC 259 ms
114,536 KB
testcase_62 RE -
testcase_63 AC 260 ms
114,196 KB
testcase_64 AC 206 ms
97,352 KB
testcase_65 AC 266 ms
114,620 KB
testcase_66 AC 274 ms
119,176 KB
testcase_67 RE -
testcase_68 AC 231 ms
102,956 KB
testcase_69 RE -
testcase_70 AC 436 ms
112,108 KB
testcase_71 AC 207 ms
95,696 KB
testcase_72 AC 271 ms
120,992 KB
testcase_73 AC 267 ms
116,308 KB
testcase_74 AC 215 ms
100,968 KB
testcase_75 AC 276 ms
116,044 KB
testcase_76 RE -
testcase_77 AC 214 ms
95,276 KB
testcase_78 RE -
testcase_79 AC 207 ms
93,528 KB
testcase_80 AC 257 ms
120,564 KB
testcase_81 AC 273 ms
116,324 KB
testcase_82 AC 242 ms
107,544 KB
testcase_83 AC 249 ms
107,912 KB
testcase_84 AC 239 ms
103,960 KB
testcase_85 AC 155 ms
79,468 KB
testcase_86 AC 237 ms
101,028 KB
testcase_87 AC 260 ms
111,532 KB
testcase_88 AC 201 ms
91,800 KB
testcase_89 AC 243 ms
107,484 KB
testcase_90 AC 195 ms
89,632 KB
testcase_91 AC 237 ms
110,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

from collections import deque

# 最小値、傾き単調減少、x単調増加
class ConvexHullTrick:
    def __init__(self):
        self.ab = deque()

    def add_line(self, a, b):
        if self.ab and a == self.ab[-1][0]:
            if b >= self.ab[-1][1]: return
            self.ab.pop()
        while len(self.ab) > 1:
            c, d = self.ab[-1]
            e, f = self.ab[-2]
            if (b-d)*(e-c) > (d-f)*(c-a): break
            self.ab.pop()
        self.ab.append((a, b))

    def min(self, x):
        if not self.ab: return (1 << 63)-1
        while len(self.ab) > 1:
            a, b = self.ab[0]
            c, d = self.ab[1]
            if a*x+b < c*x+d: break
            self.ab.popleft()
        a, b = self.ab[0]
        return a*x+b

n, a, b, w = LI()
dd = LI()

cht = ConvexHullTrick()
cht.add_line(0, 2*w)

ans = w+n*(n+1)//2*b-a*n
for i, d in enumerate(dd):
    cur = (cht.min(i)+i*(b*(i+1)-2*a)+2*d)//2
    r = n-i-1
    ans = min(ans, cur+r*(r+1)//2*b-a*r)
    i += 1
    cht.add_line(-2*b*i, 2*cur+i*(b*(i-1)+2*a))

print(ans)
0