結果
| 問題 |
No.1816 MUL-DIV Game
|
| ユーザー |
hiraku
|
| 提出日時 | 2022-01-22 08:56:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 275 ms / 2,000 ms |
| コード長 | 458 bytes |
| コンパイル時間 | 375 ms |
| コンパイル使用メモリ | 82,504 KB |
| 実行使用メモリ | 92,416 KB |
| 最終ジャッジ日時 | 2024-11-26 23:34:13 |
| 合計ジャッジ時間 | 6,116 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
import heapq
n = int(input())
a = list(map(int, input().split()))
hq = a[:]
hq2 = [-x for x in a]
heapq.heapify(hq)
heapq.heapify(hq2)
for i in range(n - 1):
if i % 2 == 0:
x = heapq.heappop(hq)
y = heapq.heappop(hq)
heapq.heappush(hq, x * y)
heapq.heappush(hq2, -x * y)
else:
heapq.heappop(hq2)
heapq.heappop(hq2)
heapq.heappush(hq, 1)
heapq.heappush(hq2, -1)
print(heapq.heappop(hq))
hiraku