結果

問題 No.1816 MUL-DIV Game
ユーザー lam6er
提出日時 2025-04-15 21:10:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 97,300 KB
最終ジャッジ日時 2025-04-15 21:16:18
合計ジャッジ時間 5,833 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def main():
    import sys
    input = sys.stdin.read().split()
    N = int(input[0])
    A = list(map(int, input[1:N+1]))
    
    if N == 1:
        print(A[0])
        return
    
    heap = []
    for num in A:
        heapq.heappush(heap, -num)
    
    for i in range(N-1):
        if i % 2 == 0:  # Alice's turn
            a = -heapq.heappop(heap)
            b = -heapq.heappop(heap)
            heapq.heappush(heap, -(a * b))
        else:  # Bob's turn
            a = -heapq.heappop(heap)
            b = -heapq.heappop(heap)
            heapq.heappush(heap, -1)
    
    print(-heap[0])

if __name__ == "__main__":
    main()
0