結果

問題 No.1290 Addition and Subtraction Operation
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-18 12:28:01
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 709 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 602,308 KB
最終ジャッジ日時 2023-10-12 21:10:49
合計ジャッジ時間 15,881 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,332 KB
testcase_01 AC 71 ms
71,324 KB
testcase_02 AC 72 ms
70,900 KB
testcase_03 AC 71 ms
71,140 KB
testcase_04 AC 72 ms
71,356 KB
testcase_05 AC 72 ms
71,020 KB
testcase_06 AC 72 ms
71,048 KB
testcase_07 AC 71 ms
71,272 KB
testcase_08 AC 72 ms
71,180 KB
testcase_09 AC 71 ms
71,184 KB
testcase_10 AC 70 ms
71,176 KB
testcase_11 AC 71 ms
71,260 KB
testcase_12 AC 71 ms
71,268 KB
testcase_13 AC 71 ms
71,144 KB
testcase_14 AC 72 ms
71,288 KB
testcase_15 AC 71 ms
71,300 KB
testcase_16 AC 70 ms
71,148 KB
testcase_17 AC 71 ms
71,300 KB
testcase_18 AC 70 ms
71,252 KB
testcase_19 AC 71 ms
71,204 KB
testcase_20 AC 70 ms
71,324 KB
testcase_21 AC 73 ms
71,248 KB
testcase_22 AC 74 ms
71,244 KB
testcase_23 AC 74 ms
71,180 KB
testcase_24 AC 72 ms
71,376 KB
testcase_25 AC 72 ms
71,088 KB
testcase_26 AC 73 ms
71,320 KB
testcase_27 AC 72 ms
70,980 KB
testcase_28 AC 71 ms
71,184 KB
testcase_29 AC 71 ms
71,300 KB
testcase_30 AC 71 ms
71,248 KB
testcase_31 AC 70 ms
71,316 KB
testcase_32 AC 72 ms
71,176 KB
testcase_33 AC 71 ms
71,132 KB
testcase_34 AC 71 ms
71,096 KB
testcase_35 AC 71 ms
71,240 KB
testcase_36 AC 72 ms
71,132 KB
testcase_37 AC 72 ms
71,348 KB
testcase_38 AC 71 ms
70,840 KB
testcase_39 AC 72 ms
71,252 KB
testcase_40 AC 70 ms
71,192 KB
testcase_41 AC 71 ms
71,248 KB
testcase_42 AC 155 ms
90,144 KB
testcase_43 AC 158 ms
89,944 KB
testcase_44 AC 159 ms
90,044 KB
testcase_45 AC 159 ms
89,976 KB
testcase_46 AC 156 ms
89,964 KB
testcase_47 AC 164 ms
89,964 KB
testcase_48 AC 155 ms
90,132 KB
testcase_49 AC 153 ms
90,080 KB
testcase_50 AC 154 ms
90,040 KB
testcase_51 AC 154 ms
90,056 KB
testcase_52 AC 152 ms
90,180 KB
testcase_53 AC 156 ms
90,024 KB
testcase_54 AC 154 ms
90,020 KB
testcase_55 AC 154 ms
90,020 KB
testcase_56 AC 157 ms
90,128 KB
testcase_57 AC 132 ms
89,632 KB
testcase_58 AC 151 ms
95,732 KB
testcase_59 AC 132 ms
90,816 KB
testcase_60 AC 175 ms
95,120 KB
testcase_61 AC 162 ms
95,132 KB
testcase_62 AC 159 ms
93,400 KB
testcase_63 AC 150 ms
96,980 KB
testcase_64 AC 115 ms
97,320 KB
testcase_65 AC 119 ms
89,516 KB
testcase_66 AC 147 ms
90,632 KB
testcase_67 AC 179 ms
95,640 KB
testcase_68 AC 161 ms
92,312 KB
testcase_69 AC 152 ms
96,324 KB
testcase_70 AC 134 ms
89,656 KB
testcase_71 AC 144 ms
90,868 KB
testcase_72 AC 119 ms
89,604 KB
testcase_73 AC 172 ms
101,080 KB
testcase_74 AC 108 ms
96,292 KB
testcase_75 AC 116 ms
89,516 KB
testcase_76 AC 134 ms
89,844 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
    for r in stc:
      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