結果

問題 No.1290 Addition and Subtraction Operation
ユーザー chineristACchineristAC
提出日時 2020-11-13 22:44:55
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 858 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 639,664 KB
最終ジャッジ日時 2023-09-30 03:46:13
合計ジャッジ時間 18,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,316 KB
testcase_01 AC 77 ms
71,188 KB
testcase_02 AC 78 ms
71,392 KB
testcase_03 AC 77 ms
71,416 KB
testcase_04 AC 75 ms
71,304 KB
testcase_05 AC 79 ms
71,280 KB
testcase_06 AC 78 ms
71,572 KB
testcase_07 AC 79 ms
71,600 KB
testcase_08 AC 77 ms
71,284 KB
testcase_09 AC 76 ms
71,488 KB
testcase_10 AC 78 ms
71,408 KB
testcase_11 AC 77 ms
71,384 KB
testcase_12 AC 77 ms
71,376 KB
testcase_13 AC 78 ms
71,120 KB
testcase_14 AC 78 ms
71,288 KB
testcase_15 AC 79 ms
71,156 KB
testcase_16 AC 80 ms
71,572 KB
testcase_17 AC 80 ms
71,560 KB
testcase_18 AC 78 ms
71,116 KB
testcase_19 AC 78 ms
71,288 KB
testcase_20 AC 79 ms
71,340 KB
testcase_21 AC 80 ms
71,600 KB
testcase_22 AC 78 ms
71,116 KB
testcase_23 AC 79 ms
71,112 KB
testcase_24 AC 79 ms
71,476 KB
testcase_25 AC 79 ms
71,476 KB
testcase_26 AC 79 ms
71,356 KB
testcase_27 AC 79 ms
71,512 KB
testcase_28 AC 79 ms
71,232 KB
testcase_29 AC 78 ms
71,488 KB
testcase_30 AC 77 ms
71,464 KB
testcase_31 AC 80 ms
71,460 KB
testcase_32 AC 78 ms
71,344 KB
testcase_33 AC 78 ms
71,372 KB
testcase_34 AC 78 ms
71,448 KB
testcase_35 AC 78 ms
71,568 KB
testcase_36 AC 77 ms
71,536 KB
testcase_37 AC 79 ms
71,300 KB
testcase_38 AC 78 ms
71,600 KB
testcase_39 AC 77 ms
71,432 KB
testcase_40 AC 75 ms
71,228 KB
testcase_41 AC 76 ms
71,132 KB
testcase_42 AC 114 ms
78,744 KB
testcase_43 AC 116 ms
78,896 KB
testcase_44 AC 119 ms
78,848 KB
testcase_45 AC 112 ms
78,448 KB
testcase_46 AC 113 ms
78,448 KB
testcase_47 AC 120 ms
78,640 KB
testcase_48 AC 115 ms
78,840 KB
testcase_49 AC 116 ms
78,668 KB
testcase_50 AC 115 ms
78,668 KB
testcase_51 AC 114 ms
78,612 KB
testcase_52 AC 113 ms
78,672 KB
testcase_53 AC 113 ms
78,608 KB
testcase_54 AC 113 ms
78,760 KB
testcase_55 AC 116 ms
78,440 KB
testcase_56 AC 113 ms
78,508 KB
testcase_57 AC 132 ms
93,840 KB
testcase_58 AC 145 ms
94,080 KB
testcase_59 AC 133 ms
93,936 KB
testcase_60 AC 439 ms
119,712 KB
testcase_61 AC 499 ms
263,920 KB
testcase_62 AC 340 ms
105,980 KB
testcase_63 AC 141 ms
94,056 KB
testcase_64 AC 110 ms
90,920 KB
testcase_65 AC 126 ms
94,076 KB
testcase_66 AC 158 ms
94,160 KB
testcase_67 AC 448 ms
122,024 KB
testcase_68 AC 171 ms
94,008 KB
testcase_69 AC 141 ms
94,240 KB
testcase_70 AC 137 ms
94,172 KB
testcase_71 AC 155 ms
94,084 KB
testcase_72 AC 125 ms
94,168 KB
testcase_73 AC 165 ms
94,296 KB
testcase_74 AC 106 ms
90,680 KB
testcase_75 AC 120 ms
94,240 KB
testcase_76 AC 136 ms
93,832 KB
testcase_77 AC 372 ms
104,604 KB
testcase_78 AC 402 ms
170,616 KB
testcase_79 AC 233 ms
95,636 KB
testcase_80 MLE -
testcase_81 MLE -
testcase_82 AC 352 ms
95,364 KB
testcase_83 AC 383 ms
111,300 KB
testcase_84 AC 182 ms
95,692 KB
testcase_85 AC 132 ms
95,200 KB
testcase_86 AC 121 ms
95,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline
sys.setrecursionlimit(2*10**5)

N,M = map(int,input().split())
B = list(map(int,input().split()))
for i in range(1,N,2):
    B[i] = -B[i]
for i in range(N-1,0,-1):
    B[i] -= B[i-1]

edge = [[] for i in range(N+1)]
for _ in range(M):
    l,r = map(int,input().split())
    edge[r].append(l-1)
    edge[l-1].append(r)

used = [False]*(N+1)
tmp = 0

def dfs(v):
    global tmp
    for nv in edge[v]:
        if not used[nv]:
            used[nv] = True
            if nv!=N:
                tmp += B[nv]
            dfs(nv)

for i in range(N):
    tmp = 0
    check = used[-1]
    if not used[i]:
        used[i] = True
        tmp += B[i]
        dfs(i)
        check2 = used[-1]
        if not check and check2:
            continue
        else:
            if tmp!=0:
                exit(print("NO"))

print("YES")
0