結果

問題 No.1375 Divide and Update
ユーザー ayaoniayaoni
提出日時 2021-02-05 22:09:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 133,584 KB
最終ジャッジ日時 2023-09-15 08:20:10
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,308 KB
testcase_01 AC 72 ms
71,396 KB
testcase_02 AC 71 ms
71,236 KB
testcase_03 AC 72 ms
71,352 KB
testcase_04 AC 72 ms
71,604 KB
testcase_05 AC 71 ms
71,164 KB
testcase_06 AC 71 ms
71,240 KB
testcase_07 AC 71 ms
71,172 KB
testcase_08 AC 72 ms
71,260 KB
testcase_09 AC 73 ms
71,600 KB
testcase_10 WA -
testcase_11 AC 161 ms
103,740 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 189 ms
133,584 KB
testcase_19 AC 185 ms
133,276 KB
testcase_20 AC 163 ms
121,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,X,Y = MI()
A = LI()
SA = sum(A)

S = [X-a for a in A]
T = [Y-a for a in A]

U = [S[0]]
x = S[0]
y = 0
for i in range(1,N-1):
    s = S[i]
    if x+y >= 0 and y+s > 0:
        x += y+s
        y = 0
    elif x <= s:
        x = s
        y = 0
    else:
        y += s
    U.append(x)

T.reverse()
V = [T[0]]
x = T[0]
y = 0
for i in range(1,N-1):
    t = T[i]
    if x+y >= 0 and y+t > 0:
        x += y+t
        y = 0
    elif x <= t:
        x = t
        y = 0
    else:
        y += t
    V.append(x)

for i in range(1,N-1):
    print(SA+U[i-1]+V[N-2-i])
0