結果
| 問題 | No.1816 MUL-DIV Game | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:50:16 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,098 bytes | 
| コンパイル時間 | 193 ms | 
| コンパイル使用メモリ | 81,832 KB | 
| 実行使用メモリ | 97,504 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:50:27 | 
| 合計ジャッジ時間 | 6,219 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 WA * 19 | 
ソースコード
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
    
    max_heap = [-x for x in A]
    heapq.heapify(max_heap)
    
    min_heap = A.copy()
    heapq.heapify(min_heap)
    
    total_ops = N - 1
    alice_ops = (total_ops + 1) // 2
    bob_ops = total_ops // 2
    
    current_ops = 0
    is_alice_turn = True
    
    while current_ops < total_ops:
        if is_alice_turn:
            x = -heapq.heappop(max_heap)
            y = -heapq.heappop(max_heap)
            product = x * y
            heapq.heappush(max_heap, -product)
            heapq.heappush(min_heap, product)
        else:
            x = heapq.heappop(min_heap)
            y = -heapq.heappop(max_heap)
            z = (x + y - 1) // y  # Equivalent to ceiling(x/y)
            heapq.heappush(max_heap, -z)
            heapq.heappush(min_heap, z)
        is_alice_turn = not is_alice_turn
        current_ops += 1
    
    print(-max_heap[0])
if __name__ == "__main__":
    main()
            
            
            
        