結果
問題 |
No.2812 Plus Minus Blackboard
|
ユーザー |
![]() |
提出日時 | 2024-07-22 15:09:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 543 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 381 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 30,372 KB |
最終ジャッジ日時 | 2025-06-20 02:16:14 |
合計ジャッジ時間 | 7,957 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
import sys input = sys.stdin.readline from heapq import heappop,heappush N=int(input()) A=list(map(int,input().split())) P=[] M=[] for a in A: if a>0: P.append(a) elif a<0: M.append(-a) P.sort() M.sort() while P and M: x=heappop(P) y=heappop(M) k=x-y if k>0: heappush(P,k) elif k<0: heappush(M,-k) if len(P)+len(M)<=1: print("Yes") else: print("No")