結果

問題 No.1990 Candy Boxes
ユーザー mkawa2mkawa2
提出日時 2022-06-25 09:04:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,625 bytes
コンパイル時間 1,232 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 103,932 KB
最終ジャッジ日時 2023-08-12 23:13:43
合計ジャッジ時間 9,338 ms
ジャッジサーバーID
(参考情報)
judge7 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,256 KB
testcase_01 AC 73 ms
71,124 KB
testcase_02 AC 79 ms
71,044 KB
testcase_03 WA -
testcase_04 AC 73 ms
71,060 KB
testcase_05 AC 70 ms
71,108 KB
testcase_06 AC 70 ms
71,032 KB
testcase_07 AC 72 ms
71,300 KB
testcase_08 AC 69 ms
71,392 KB
testcase_09 AC 70 ms
71,024 KB
testcase_10 AC 71 ms
70,828 KB
testcase_11 WA -
testcase_12 AC 114 ms
95,872 KB
testcase_13 AC 117 ms
95,884 KB
testcase_14 AC 95 ms
91,780 KB
testcase_15 AC 97 ms
95,880 KB
testcase_16 AC 98 ms
96,296 KB
testcase_17 AC 98 ms
98,756 KB
testcase_18 AC 99 ms
98,996 KB
testcase_19 AC 98 ms
97,620 KB
testcase_20 AC 106 ms
100,128 KB
testcase_21 AC 101 ms
100,044 KB
testcase_22 AC 93 ms
92,264 KB
testcase_23 AC 102 ms
93,920 KB
testcase_24 AC 104 ms
93,668 KB
testcase_25 AC 113 ms
103,932 KB
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
権限があれば一括ダウンロードができます

ソースコード

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 heapq import *

n = II()
aa = [0]+LI()

now=0
for i in range(n):
    now=aa[i+1]-now
    if now<0:
        print("No")
        exit()
if now:
    print("No")
    exit()

q = []
dd = []
for i in range(n):
    dd.append(aa[i+1]-aa[i])
    if dd[-1] & 1 == 0: heappush(q, i)
dd.append(0)
pDB(q, dd)

for i in range(n-1):
    if dd[i] & 1 == 0: continue
    if dd[i+1] & 1 == 0:
        d = dd[i]
        dd[i] -= d
        dd[i+2] += d
    else:
        while q and (q[0] <= i or dd[q[0]] & 1): heappop(q)
        if not q:
            print("No")
            exit()
        j = q[0]
        if dd[i+1] & 1 and dd[j+1] & 1: heappush(q, j+1)
        dd[j] += dd[i]
        dd[j+1] += dd[i+1]
        dd[i] = dd[i+1] = 0
    pDB(q, dd)

def ng(si):
    now = 0
    for i in range(si, n, 2):
        now += dd[i]
        if now < 0: return True
    return False

print("No" if ng(0) or ng(1) else "Yes")
0