結果

問題 No.2812 Plus Minus Blackboard
ユーザー moon17
提出日時 2024-07-19 22:32:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 377 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 67,448 KB
最終ジャッジ日時 2025-04-08 23:43:51
合計ジャッジ時間 2,499 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from sortedcontainers import*
n,*a=map(int,open(0).read().split())
p=SortedList()
q=SortedList()
for i in a:
  if 0<=i:
    p.add(i)
  else:
    q.add(i)
while (p and q)or(len(p)>1 and p[0]==0):
  if q:
    i,j=p.pop(0),q.pop()
  else:
    i,j=p.pop(0),p.pop()
  nxt=i+j
  if nxt>=0:
    p.add(nxt)
  else:
    q.add(nxt)
if len(p)+len(q)==1:
  print('Yes')
else:
  print('No')
0