結果
問題 | No.2812 Plus Minus Blackboard |
ユーザー |
|
提出日時 | 2024-10-23 01:44:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 799 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 105,240 KB |
最終ジャッジ日時 | 2024-10-23 01:44:27 |
合計ジャッジ時間 | 6,209 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 1 |
ソースコード
## https://yukicoder.me/problems/no/2812import heapqdef main():N = int(input())A = list(map(int, input().split()))A.sort()m_array = []p_queue = []for a in A:if a < 0:m_array.append(a)else:heapq.heappush(p_queue,a)m_index = len(m_array) - 1while m_index >= 0:m = m_array[m_index]while m < 0 and len(p_queue) > 0:a = heapq.heappop(p_queue)m += aif m >= 0:heapq.heappush(p_queue, m)m_index -= 1else:breakif m_index == -1 and len(p_queue) == 1:print("Yes")elif m_index == 0 and len(p_queue) == 0:print("Yes")else:print("No")if __name__ == "__main__":main()