結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,400 KB
testcase_01 AC 77 ms
71,516 KB
testcase_02 AC 76 ms
71,404 KB
testcase_03 AC 77 ms
71,392 KB
testcase_04 AC 77 ms
71,320 KB
testcase_05 AC 75 ms
71,464 KB
testcase_06 AC 76 ms
71,544 KB
testcase_07 AC 76 ms
71,612 KB
testcase_08 AC 77 ms
71,464 KB
testcase_09 AC 75 ms
71,472 KB
testcase_10 AC 77 ms
71,332 KB
testcase_11 AC 74 ms
71,388 KB
testcase_12 AC 76 ms
71,448 KB
testcase_13 AC 75 ms
71,436 KB
testcase_14 AC 77 ms
71,240 KB
testcase_15 AC 77 ms
71,220 KB
testcase_16 AC 76 ms
71,516 KB
testcase_17 AC 77 ms
71,396 KB
testcase_18 AC 77 ms
71,224 KB
testcase_19 AC 76 ms
71,292 KB
testcase_20 AC 78 ms
71,396 KB
testcase_21 AC 77 ms
71,628 KB
testcase_22 AC 76 ms
71,436 KB
testcase_23 AC 78 ms
71,248 KB
testcase_24 AC 77 ms
71,300 KB
testcase_25 AC 78 ms
71,376 KB
testcase_26 AC 77 ms
71,332 KB
testcase_27 AC 78 ms
71,244 KB
testcase_28 AC 77 ms
71,236 KB
testcase_29 AC 77 ms
71,132 KB
testcase_30 AC 78 ms
71,644 KB
testcase_31 AC 76 ms
71,624 KB
testcase_32 AC 77 ms
71,288 KB
testcase_33 AC 77 ms
71,412 KB
testcase_34 AC 77 ms
71,456 KB
testcase_35 AC 78 ms
71,420 KB
testcase_36 AC 78 ms
71,296 KB
testcase_37 AC 77 ms
71,600 KB
testcase_38 AC 76 ms
71,108 KB
testcase_39 AC 77 ms
71,464 KB
testcase_40 AC 76 ms
71,140 KB
testcase_41 AC 76 ms
71,292 KB
testcase_42 AC 112 ms
78,676 KB
testcase_43 AC 113 ms
78,652 KB
testcase_44 AC 112 ms
78,668 KB
testcase_45 AC 112 ms
78,936 KB
testcase_46 AC 114 ms
78,764 KB
testcase_47 AC 113 ms
78,724 KB
testcase_48 AC 111 ms
78,704 KB
testcase_49 AC 112 ms
78,724 KB
testcase_50 AC 112 ms
78,532 KB
testcase_51 AC 111 ms
78,832 KB
testcase_52 AC 113 ms
78,616 KB
testcase_53 AC 112 ms
78,752 KB
testcase_54 AC 111 ms
78,668 KB
testcase_55 AC 112 ms
78,728 KB
testcase_56 AC 110 ms
78,836 KB
testcase_57 AC 128 ms
94,152 KB
testcase_58 AC 138 ms
93,928 KB
testcase_59 AC 128 ms
93,964 KB
testcase_60 AC 430 ms
119,596 KB
testcase_61 AC 486 ms
262,672 KB
testcase_62 AC 332 ms
104,376 KB
testcase_63 AC 134 ms
93,956 KB
testcase_64 AC 107 ms
90,628 KB
testcase_65 AC 124 ms
94,156 KB
testcase_66 AC 155 ms
94,144 KB
testcase_67 AC 435 ms
121,940 KB
testcase_68 AC 170 ms
94,152 KB
testcase_69 AC 137 ms
93,872 KB
testcase_70 AC 135 ms
93,952 KB
testcase_71 AC 155 ms
94,108 KB
testcase_72 AC 123 ms
93,924 KB
testcase_73 AC 162 ms
93,980 KB
testcase_74 AC 101 ms
90,472 KB
testcase_75 AC 123 ms
94,304 KB
testcase_76 AC 137 ms
94,160 KB
testcase_77 AC 365 ms
103,608 KB
testcase_78 AC 393 ms
172,460 KB
testcase_79 AC 228 ms
95,648 KB
testcase_80 MLE -
testcase_81 MLE -
testcase_82 AC 243 ms
95,800 KB
testcase_83 AC 374 ms
112,244 KB
testcase_84 AC 176 ms
95,600 KB
testcase_85 AC 132 ms
95,196 KB
testcase_86 AC 118 ms
95,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

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