結果
問題 | No.1290 Addition and Subtraction Operation |
ユーザー | tamato |
提出日時 | 2020-11-13 23:25:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 258 ms / 2,000 ms |
コード長 | 1,338 bytes |
コンパイル時間 | 479 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 100,480 KB |
最終ジャッジ日時 | 2024-07-22 22:17:05 |
合計ジャッジ時間 | 11,029 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
54,272 KB |
testcase_01 | AC | 46 ms
54,144 KB |
testcase_02 | AC | 45 ms
53,888 KB |
testcase_03 | AC | 44 ms
54,144 KB |
testcase_04 | AC | 45 ms
54,144 KB |
testcase_05 | AC | 46 ms
53,760 KB |
testcase_06 | AC | 46 ms
53,888 KB |
testcase_07 | AC | 47 ms
54,400 KB |
testcase_08 | AC | 46 ms
54,400 KB |
testcase_09 | AC | 48 ms
53,888 KB |
testcase_10 | AC | 46 ms
54,016 KB |
testcase_11 | AC | 48 ms
54,272 KB |
testcase_12 | AC | 47 ms
53,888 KB |
testcase_13 | AC | 47 ms
54,272 KB |
testcase_14 | AC | 47 ms
53,888 KB |
testcase_15 | AC | 52 ms
54,272 KB |
testcase_16 | AC | 47 ms
54,400 KB |
testcase_17 | AC | 47 ms
54,272 KB |
testcase_18 | AC | 47 ms
54,144 KB |
testcase_19 | AC | 49 ms
53,760 KB |
testcase_20 | AC | 47 ms
54,144 KB |
testcase_21 | AC | 46 ms
53,888 KB |
testcase_22 | AC | 46 ms
54,144 KB |
testcase_23 | AC | 46 ms
54,400 KB |
testcase_24 | AC | 46 ms
54,144 KB |
testcase_25 | AC | 46 ms
54,272 KB |
testcase_26 | AC | 45 ms
54,144 KB |
testcase_27 | AC | 47 ms
54,400 KB |
testcase_28 | AC | 46 ms
54,196 KB |
testcase_29 | AC | 46 ms
54,400 KB |
testcase_30 | AC | 47 ms
54,272 KB |
testcase_31 | AC | 47 ms
54,144 KB |
testcase_32 | AC | 47 ms
54,400 KB |
testcase_33 | AC | 46 ms
54,016 KB |
testcase_34 | AC | 46 ms
54,144 KB |
testcase_35 | AC | 49 ms
54,272 KB |
testcase_36 | AC | 47 ms
54,144 KB |
testcase_37 | AC | 47 ms
54,272 KB |
testcase_38 | AC | 48 ms
54,272 KB |
testcase_39 | AC | 46 ms
54,144 KB |
testcase_40 | AC | 46 ms
54,400 KB |
testcase_41 | AC | 47 ms
53,888 KB |
testcase_42 | AC | 81 ms
76,852 KB |
testcase_43 | AC | 83 ms
76,864 KB |
testcase_44 | AC | 80 ms
76,872 KB |
testcase_45 | AC | 80 ms
76,672 KB |
testcase_46 | AC | 80 ms
77,184 KB |
testcase_47 | AC | 82 ms
76,800 KB |
testcase_48 | AC | 80 ms
76,788 KB |
testcase_49 | AC | 86 ms
76,928 KB |
testcase_50 | AC | 82 ms
76,776 KB |
testcase_51 | AC | 81 ms
76,804 KB |
testcase_52 | AC | 80 ms
76,900 KB |
testcase_53 | AC | 82 ms
77,184 KB |
testcase_54 | AC | 83 ms
76,928 KB |
testcase_55 | AC | 80 ms
76,800 KB |
testcase_56 | AC | 81 ms
77,056 KB |
testcase_57 | AC | 126 ms
99,888 KB |
testcase_58 | AC | 131 ms
99,840 KB |
testcase_59 | AC | 127 ms
100,016 KB |
testcase_60 | AC | 226 ms
99,928 KB |
testcase_61 | AC | 198 ms
99,840 KB |
testcase_62 | AC | 208 ms
99,840 KB |
testcase_63 | AC | 132 ms
99,840 KB |
testcase_64 | AC | 101 ms
96,272 KB |
testcase_65 | AC | 118 ms
99,840 KB |
testcase_66 | AC | 135 ms
99,840 KB |
testcase_67 | AC | 228 ms
100,108 KB |
testcase_68 | AC | 153 ms
99,840 KB |
testcase_69 | AC | 132 ms
99,840 KB |
testcase_70 | AC | 131 ms
99,840 KB |
testcase_71 | AC | 141 ms
99,876 KB |
testcase_72 | AC | 120 ms
100,096 KB |
testcase_73 | AC | 145 ms
99,968 KB |
testcase_74 | AC | 93 ms
94,080 KB |
testcase_75 | AC | 117 ms
100,096 KB |
testcase_76 | AC | 131 ms
100,096 KB |
testcase_77 | AC | 226 ms
100,200 KB |
testcase_78 | AC | 222 ms
100,352 KB |
testcase_79 | AC | 204 ms
100,352 KB |
testcase_80 | AC | 258 ms
100,224 KB |
testcase_81 | AC | 248 ms
100,480 KB |
testcase_82 | AC | 145 ms
100,276 KB |
testcase_83 | AC | 224 ms
100,372 KB |
testcase_84 | AC | 168 ms
100,480 KB |
testcase_85 | AC | 133 ms
100,352 KB |
testcase_86 | AC | 115 ms
100,316 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys from collections import deque input = sys.stdin.buffer.readline N, M = map(int, input().split()) B = list(map(int, input().split())) B = [b * (-1)**i for i, b in enumerate(B)] C = [0] * (N+1) C[0] = B[0] for i in range(1, N): C[i] = B[i] - B[i-1] C[N] = -B[-1] adj = [[] for _ in range(N + 1)] for _ in range(M): l, r = map(int, input().split()) l -= 1 r -= 1 adj[l].append(r+1) adj[r+1].append(l) seen = [0] * (N+1) par = [-1] * (N+1) dp = [0] * (N+1) for v0 in range(N+1): if seen[v0]: continue que = deque() que.append(v0) seen[v0] = 1 seq = [] while que: v = que.popleft() seq.append(v) for u in adj[v]: if not seen[u]: par[u] = v que.append(u) seen[u] = 1 seq.reverse() for v in seq: if v != v0: x = C[v] - dp[v] dp[v] += x dp[par[v]] -= x else: if dp[v] != C[v]: print("NO") exit() print("YES") if __name__ == '__main__': main()