結果

問題 No.1290 Addition and Subtraction Operation
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-18 12:29:59
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 723 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 516,720 KB
最終ジャッジ日時 2023-10-12 21:12:41
合計ジャッジ時間 14,667 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,688 KB
testcase_01 AC 72 ms
71,436 KB
testcase_02 AC 73 ms
71,240 KB
testcase_03 AC 73 ms
71,288 KB
testcase_04 AC 75 ms
71,324 KB
testcase_05 AC 73 ms
71,472 KB
testcase_06 AC 75 ms
71,296 KB
testcase_07 AC 71 ms
71,164 KB
testcase_08 AC 73 ms
71,244 KB
testcase_09 AC 73 ms
71,384 KB
testcase_10 AC 71 ms
71,324 KB
testcase_11 AC 72 ms
71,288 KB
testcase_12 AC 73 ms
71,328 KB
testcase_13 AC 72 ms
71,176 KB
testcase_14 AC 72 ms
71,476 KB
testcase_15 AC 72 ms
71,328 KB
testcase_16 AC 73 ms
71,184 KB
testcase_17 AC 74 ms
71,364 KB
testcase_18 AC 72 ms
71,340 KB
testcase_19 AC 73 ms
71,260 KB
testcase_20 AC 72 ms
71,240 KB
testcase_21 AC 71 ms
71,160 KB
testcase_22 AC 74 ms
71,116 KB
testcase_23 AC 72 ms
71,384 KB
testcase_24 AC 74 ms
71,252 KB
testcase_25 AC 73 ms
71,148 KB
testcase_26 AC 74 ms
71,384 KB
testcase_27 AC 73 ms
71,324 KB
testcase_28 AC 72 ms
71,180 KB
testcase_29 AC 73 ms
71,364 KB
testcase_30 AC 73 ms
71,480 KB
testcase_31 AC 72 ms
71,376 KB
testcase_32 AC 72 ms
71,320 KB
testcase_33 AC 73 ms
71,284 KB
testcase_34 AC 73 ms
70,956 KB
testcase_35 AC 73 ms
71,116 KB
testcase_36 AC 74 ms
71,404 KB
testcase_37 AC 73 ms
70,928 KB
testcase_38 AC 71 ms
71,172 KB
testcase_39 AC 71 ms
71,180 KB
testcase_40 AC 72 ms
71,252 KB
testcase_41 AC 70 ms
71,380 KB
testcase_42 AC 170 ms
90,140 KB
testcase_43 AC 156 ms
90,160 KB
testcase_44 AC 155 ms
90,128 KB
testcase_45 AC 152 ms
90,268 KB
testcase_46 AC 153 ms
89,984 KB
testcase_47 AC 154 ms
89,988 KB
testcase_48 AC 156 ms
90,344 KB
testcase_49 AC 158 ms
90,388 KB
testcase_50 AC 156 ms
90,264 KB
testcase_51 AC 152 ms
90,340 KB
testcase_52 AC 154 ms
90,264 KB
testcase_53 AC 158 ms
90,228 KB
testcase_54 AC 156 ms
90,260 KB
testcase_55 AC 155 ms
90,344 KB
testcase_56 AC 153 ms
90,148 KB
testcase_57 AC 131 ms
89,852 KB
testcase_58 AC 152 ms
95,492 KB
testcase_59 AC 135 ms
91,024 KB
testcase_60 AC 179 ms
95,480 KB
testcase_61 AC 161 ms
95,384 KB
testcase_62 AC 160 ms
93,488 KB
testcase_63 AC 154 ms
97,040 KB
testcase_64 AC 119 ms
97,408 KB
testcase_65 AC 121 ms
89,568 KB
testcase_66 AC 152 ms
90,812 KB
testcase_67 AC 177 ms
95,368 KB
testcase_68 AC 162 ms
92,496 KB
testcase_69 AC 155 ms
96,524 KB
testcase_70 AC 139 ms
89,780 KB
testcase_71 AC 149 ms
90,980 KB
testcase_72 AC 124 ms
89,788 KB
testcase_73 AC 174 ms
101,044 KB
testcase_74 AC 111 ms
96,288 KB
testcase_75 AC 122 ms
89,936 KB
testcase_76 AC 140 ms
89,956 KB
testcase_77 MLE -
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
    for r in rary[i]:
      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