結果

問題 No.1290 Addition and Subtraction Operation
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-18 12:31:16
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 742 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 267,872 KB
最終ジャッジ日時 2023-10-12 21:13:49
合計ジャッジ時間 14,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,836 KB
testcase_01 AC 71 ms
71,164 KB
testcase_02 AC 73 ms
70,920 KB
testcase_03 AC 74 ms
71,104 KB
testcase_04 AC 76 ms
71,188 KB
testcase_05 AC 72 ms
71,348 KB
testcase_06 AC 72 ms
71,288 KB
testcase_07 AC 71 ms
71,216 KB
testcase_08 AC 73 ms
70,960 KB
testcase_09 AC 72 ms
71,296 KB
testcase_10 AC 72 ms
71,108 KB
testcase_11 AC 73 ms
71,332 KB
testcase_12 AC 71 ms
71,184 KB
testcase_13 AC 73 ms
70,964 KB
testcase_14 AC 72 ms
70,940 KB
testcase_15 AC 72 ms
70,960 KB
testcase_16 AC 72 ms
71,144 KB
testcase_17 AC 72 ms
71,392 KB
testcase_18 AC 71 ms
71,364 KB
testcase_19 AC 73 ms
71,192 KB
testcase_20 AC 74 ms
71,156 KB
testcase_21 AC 74 ms
71,060 KB
testcase_22 AC 73 ms
71,244 KB
testcase_23 AC 73 ms
71,408 KB
testcase_24 AC 72 ms
71,396 KB
testcase_25 AC 73 ms
71,116 KB
testcase_26 AC 71 ms
71,408 KB
testcase_27 AC 72 ms
71,156 KB
testcase_28 AC 71 ms
71,364 KB
testcase_29 AC 72 ms
71,044 KB
testcase_30 AC 72 ms
71,288 KB
testcase_31 AC 74 ms
71,188 KB
testcase_32 AC 73 ms
71,420 KB
testcase_33 AC 71 ms
71,296 KB
testcase_34 AC 72 ms
71,368 KB
testcase_35 AC 73 ms
71,124 KB
testcase_36 AC 73 ms
71,360 KB
testcase_37 AC 72 ms
71,308 KB
testcase_38 AC 72 ms
71,072 KB
testcase_39 AC 72 ms
71,288 KB
testcase_40 AC 72 ms
71,152 KB
testcase_41 AC 73 ms
71,184 KB
testcase_42 AC 159 ms
88,736 KB
testcase_43 AC 158 ms
88,928 KB
testcase_44 AC 156 ms
88,804 KB
testcase_45 AC 158 ms
88,912 KB
testcase_46 AC 157 ms
89,036 KB
testcase_47 AC 165 ms
88,768 KB
testcase_48 AC 157 ms
88,856 KB
testcase_49 AC 157 ms
88,764 KB
testcase_50 AC 155 ms
88,904 KB
testcase_51 AC 157 ms
88,880 KB
testcase_52 AC 155 ms
89,216 KB
testcase_53 AC 156 ms
88,852 KB
testcase_54 AC 157 ms
88,856 KB
testcase_55 AC 158 ms
88,808 KB
testcase_56 AC 155 ms
88,828 KB
testcase_57 AC 134 ms
89,728 KB
testcase_58 AC 159 ms
95,740 KB
testcase_59 AC 137 ms
90,844 KB
testcase_60 AC 181 ms
95,384 KB
testcase_61 AC 170 ms
95,240 KB
testcase_62 AC 166 ms
93,404 KB
testcase_63 AC 157 ms
97,196 KB
testcase_64 AC 122 ms
97,084 KB
testcase_65 AC 121 ms
89,696 KB
testcase_66 AC 153 ms
90,976 KB
testcase_67 AC 178 ms
95,316 KB
testcase_68 AC 164 ms
92,224 KB
testcase_69 AC 154 ms
96,736 KB
testcase_70 AC 138 ms
89,808 KB
testcase_71 AC 149 ms
90,924 KB
testcase_72 AC 123 ms
89,512 KB
testcase_73 AC 176 ms
101,144 KB
testcase_74 AC 110 ms
96,464 KB
testcase_75 AC 119 ms
89,544 KB
testcase_76 AC 138 ms
89,736 KB
testcase_77 TLE -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,m,b,lr):
  b=[x*(-1)**i for i,x in enumerate(b)]
  rary=[set() for _ in range(n)]
  for l,r in lr:
    rary[l-1].add(r)
  ary=[0]*(n+1)
  now=0
  for i in range(n):
    now-=ary[i]
    stc=set()
    mir=n
    d=0
    while rary[i]:
      r=rary[i].pop()
      stc.add(r)
      mir=min(mir,r)
      d=b[i]-now
    ary[mir]+=d
    while stc:
      r=stc.pop()
      if r==mir:continue
      rary[mir].add(r)
    now+=d
    if b[i]==now:
      pass
    else:
      return False
  return True

import sys
input=sys.stdin.readline
if __name__=='__main__':
  n,m=map(int,input().split())
  b=list(map(int,input().split()))
  lr=[list(map(int,input().split())) for _ in range(m)]
  ret1=main1(n,m,b,lr)
  print('YES' if ret1 else 'NO')
0