結果
問題 |
No.3165 [Cherry 7th Tune A] Croissants Continu
|
ユーザー |
|
提出日時 | 2025-06-28 09:46:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 449 bytes |
コンパイル時間 | 424 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 128,052 KB |
最終ジャッジ日時 | 2025-06-28 09:46:47 |
合計ジャッジ時間 | 15,813 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 WA * 5 |
ソースコード
import heapq T = int(input()) for _ in range(T): N = int(input()) A = list(map(int,input().split())) A = [-A[i] for i in range(N)] heapq.heapify(A) if len(A)==1: ans = 1 else: ans = 0 while len(A)>1: a = -heapq.heappop(A) b = -heapq.heappop(A) ans += 2*b if a>b: heapq.heappush(A,-(a-b)) if A: ans += 1 print(ans)