結果

問題 No.1290 Addition and Subtraction Operation
ユーザー mkawa2mkawa2
提出日時 2021-09-04 18:55:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 96,496 KB
最終ジャッジ日時 2023-08-23 08:36:33
合計ジャッジ時間 22,609 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,488 KB
testcase_01 AC 74 ms
71,260 KB
testcase_02 AC 74 ms
71,556 KB
testcase_03 AC 73 ms
71,388 KB
testcase_04 AC 74 ms
71,372 KB
testcase_05 AC 73 ms
71,504 KB
testcase_06 AC 74 ms
71,348 KB
testcase_07 AC 75 ms
71,132 KB
testcase_08 AC 76 ms
71,348 KB
testcase_09 AC 75 ms
71,384 KB
testcase_10 AC 75 ms
71,312 KB
testcase_11 AC 73 ms
71,168 KB
testcase_12 AC 75 ms
71,400 KB
testcase_13 AC 74 ms
71,316 KB
testcase_14 AC 74 ms
71,352 KB
testcase_15 AC 73 ms
71,440 KB
testcase_16 AC 73 ms
71,264 KB
testcase_17 AC 73 ms
71,168 KB
testcase_18 AC 72 ms
71,512 KB
testcase_19 AC 73 ms
71,348 KB
testcase_20 AC 72 ms
71,500 KB
testcase_21 AC 74 ms
71,176 KB
testcase_22 AC 72 ms
71,500 KB
testcase_23 AC 71 ms
71,520 KB
testcase_24 AC 72 ms
71,148 KB
testcase_25 AC 73 ms
71,356 KB
testcase_26 AC 74 ms
71,512 KB
testcase_27 AC 73 ms
71,468 KB
testcase_28 AC 73 ms
71,420 KB
testcase_29 AC 74 ms
71,336 KB
testcase_30 AC 74 ms
71,480 KB
testcase_31 AC 72 ms
71,532 KB
testcase_32 AC 73 ms
71,484 KB
testcase_33 AC 71 ms
71,172 KB
testcase_34 AC 73 ms
71,260 KB
testcase_35 AC 73 ms
71,244 KB
testcase_36 AC 75 ms
71,440 KB
testcase_37 AC 73 ms
71,364 KB
testcase_38 AC 75 ms
71,112 KB
testcase_39 AC 75 ms
71,428 KB
testcase_40 AC 74 ms
71,284 KB
testcase_41 AC 75 ms
71,384 KB
testcase_42 AC 385 ms
86,484 KB
testcase_43 AC 366 ms
86,776 KB
testcase_44 AC 367 ms
86,396 KB
testcase_45 AC 361 ms
86,604 KB
testcase_46 AC 355 ms
86,460 KB
testcase_47 AC 362 ms
86,712 KB
testcase_48 AC 362 ms
86,444 KB
testcase_49 AC 363 ms
86,472 KB
testcase_50 AC 364 ms
86,400 KB
testcase_51 AC 358 ms
86,692 KB
testcase_52 AC 362 ms
86,564 KB
testcase_53 AC 367 ms
86,488 KB
testcase_54 AC 362 ms
86,616 KB
testcase_55 AC 362 ms
86,388 KB
testcase_56 AC 363 ms
86,388 KB
testcase_57 AC 135 ms
95,356 KB
testcase_58 AC 140 ms
95,104 KB
testcase_59 AC 126 ms
95,296 KB
testcase_60 AC 164 ms
95,024 KB
testcase_61 AC 149 ms
95,160 KB
testcase_62 AC 156 ms
95,568 KB
testcase_63 AC 135 ms
95,492 KB
testcase_64 AC 115 ms
95,264 KB
testcase_65 AC 124 ms
95,296 KB
testcase_66 AC 148 ms
95,156 KB
testcase_67 AC 169 ms
95,232 KB
testcase_68 AC 155 ms
95,468 KB
testcase_69 AC 137 ms
95,176 KB
testcase_70 AC 135 ms
95,024 KB
testcase_71 AC 142 ms
95,296 KB
testcase_72 AC 127 ms
95,092 KB
testcase_73 AC 151 ms
95,584 KB
testcase_74 AC 102 ms
95,532 KB
testcase_75 AC 122 ms
95,116 KB
testcase_76 AC 137 ms
95,160 KB
testcase_77 AC 486 ms
96,324 KB
testcase_78 AC 524 ms
96,272 KB
testcase_79 AC 300 ms
96,464 KB
testcase_80 AC 659 ms
96,368 KB
testcase_81 AC 641 ms
96,248 KB
testcase_82 AC 161 ms
96,176 KB
testcase_83 AC 184 ms
96,496 KB
testcase_84 AC 230 ms
96,256 KB
testcase_85 AC 148 ms
96,260 KB
testcase_86 AC 118 ms
96,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**20
# md = 998244353
# md = 10**9+7

from heapq import *

n,m=LI()
bb=LI()
bb=[-b if i&1 else b for i,b in enumerate(bb)]
hp=[]
for _ in range(m):
    l,r=LI()
    l-=1
    heappush(hp,(l,r))

def ok():
    now=0
    cs=[0]*(n+1)
    for i,b in enumerate(bb):
        now+=cs[i]
        pr=-1
        if hp and hp[0][0]==i:
            l,r=heappop(hp)
            cs[r]-=b-now
            now=b
            pr=r
        while hp and hp[0][0]==i:
            l,r=heappop(hp)
            if pr<r:
                heappush(hp,(pr,r))
                pr=r
        if now!=b:
            return False
    return True

print("YES" if ok() else "NO")
0