結果
問題 | No.2812 Plus Minus Blackboard |
ユーザー |
![]() |
提出日時 | 2024-07-21 20:57:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 166 ms / 2,000 ms |
コード長 | 502 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,108 KB |
実行使用メモリ | 107,552 KB |
最終ジャッジ日時 | 2024-07-21 20:57:39 |
合計ジャッジ時間 | 3,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
n=int(input())a = list(map(int, input().split()))tmp=sorted(a)if tmp[0]==0 and tmp[-1]==0:print("Yes")exit()mns=[]pls=[]for i in range(n):if a[i] <0:mns.append(a[i])else:pls.append(a[i])mns.sort()pls.sort(reverse=True)while len(mns)>0 and len(pls)>0:mval=mns.pop()pval=pls.pop()if pval+mval>0:pls.append(pval+mval)elif pval+mval<0:mns.append(pval+mval)if len(mns)+len(pls)==1:print("Yes")else:print("No")