結果

問題 No.2812 Plus Minus Blackboard
ユーザー セック
提出日時 2024-07-21 20:47:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 478 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 67,580 KB
最終ジャッジ日時 2025-04-08 23:44:53
合計ジャッジ時間 2,926 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from sortedcontainers import SortedSet, SortedList, SortedDict
n=int(input())
a = list(map(int, input().split()))
#a.sort()
mns=SortedList()
pls=SortedList()
for i in range(n):
    if a[i] <0:
        mns.add(a[i])
    else:
        pls.add(a[i])
while len(mns)>0 and len(pls)>0:
    mval=mns.pop()
    pval=pls.pop(0)
    if pval+mval>0:
        pls.add(pval+mval)
    elif pval+mval<0:
        mns.add(pval+mval)
if len(mns)+len(pls)==1:
    print("Yes")
else:
    print("No")
0