結果

問題 No.1816 MUL-DIV Game
ユーザー shinichi
提出日時 2022-01-21 21:44:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 82,892 KB
実行使用メモリ 92,252 KB
最終ジャッジ日時 2024-11-25 23:19:43
合計ジャッジ時間 4,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


N = int(input())
A = list(map(int, input().split()))
A.sort()

if N == 1:
    print(A[0])
elif N == 2:
    print(A[0] * A[1])
elif N % 2 == 1:
    # 後手で終わり
    print(1)
else:
    # 先手で終わり
    heap = A[:]
    heapq.heapify(heap)
    cnt = 1
    while cnt != N // 2:
        a = heapq.heappop(heap)
        b = heapq.heappop(heap)
        c = a * b
        heapq.heappush(heap, c)
        cnt += 1
    print(heap[0])

0