結果
| 問題 |
No.2812 Plus Minus Blackboard
|
| コンテスト | |
| ユーザー |
学ぶマン
|
| 提出日時 | 2025-02-07 22:11:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 324 ms / 2,000 ms |
| コード長 | 510 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 82,132 KB |
| 実行使用メモリ | 104,904 KB |
| 最終ジャッジ日時 | 2025-06-20 02:21:25 |
| 合計ジャッジ時間 | 6,761 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
from heapq import heapify, heappop, heappush
N = int(input())
A = list(map(int, input().split()))
plus, minus = [], []
for a in A:
if a > 0:
plus.append(a)
elif a < 0:
minus.append(-a)
heapify(plus)
heapify(minus)
while plus and minus:
min_plus = heappop(plus)
max_minus = heappop(minus)
x = min_plus - max_minus
if x > 0:
heappush(plus, x)
elif x < 0:
heappush(minus, -x)
if len(plus) + len(minus) <= 1:
print('Yes')
else:
print('No')
学ぶマン