結果

問題 No.2812 Plus Minus Blackboard
ユーザー flippergo
提出日時 2025-06-07 10:18:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 104,688 KB
最終ジャッジ日時 2025-06-20 03:04:31
合計ジャッジ時間 4,405 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
P = []
M = []
for i in range(N):
    if A[i]>=0:
        P.append(A[i])
    else:
        M.append(A[i])
P = sorted(P,reverse=True)
M = sorted(M)
if len(P)>0:
    a = P.pop()
else:
    a = M.pop()
while True:
    if a>=0:
        if len(M)>0:
            b = M.pop()
            a = a+b
        elif a==0 and len(P)>0:
            b = P.pop()
            a = a+b
        else:break
    else:
        if len(P)>0:
            b = P.pop()
            a = a+b
        else:break
if len(P)+len(M)==0:
    print("Yes")
else:
    print("No")
0