結果

問題 No.1816 MUL-DIV Game
ユーザー hirakuhiraku
提出日時 2022-01-22 08:56:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 93,604 KB
最終ジャッジ日時 2023-08-17 22:42:44
合計ジャッジ時間 7,059 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,312 KB
testcase_01 AC 74 ms
71,048 KB
testcase_02 AC 80 ms
71,396 KB
testcase_03 AC 77 ms
71,396 KB
testcase_04 AC 76 ms
71,432 KB
testcase_05 AC 71 ms
71,044 KB
testcase_06 AC 74 ms
71,420 KB
testcase_07 AC 78 ms
71,376 KB
testcase_08 AC 76 ms
71,204 KB
testcase_09 AC 175 ms
79,512 KB
testcase_10 AC 211 ms
82,932 KB
testcase_11 AC 195 ms
82,916 KB
testcase_12 AC 200 ms
81,444 KB
testcase_13 AC 246 ms
86,612 KB
testcase_14 AC 213 ms
81,992 KB
testcase_15 AC 221 ms
82,932 KB
testcase_16 AC 179 ms
79,584 KB
testcase_17 AC 257 ms
90,668 KB
testcase_18 AC 243 ms
89,568 KB
testcase_19 AC 202 ms
82,728 KB
testcase_20 AC 260 ms
91,124 KB
testcase_21 AC 189 ms
81,252 KB
testcase_22 AC 178 ms
79,856 KB
testcase_23 AC 73 ms
71,220 KB
testcase_24 AC 74 ms
71,296 KB
testcase_25 AC 277 ms
93,556 KB
testcase_26 AC 289 ms
93,604 KB
testcase_27 AC 293 ms
93,420 KB
testcase_28 AC 289 ms
93,476 KB
testcase_29 AC 283 ms
93,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0