結果
問題 |
No.933 おまわりさんこいつです
|
ユーザー |
|
提出日時 | 2025-03-01 20:39:27 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 416 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 109,404 KB |
最終ジャッジ日時 | 2025-03-01 20:39:35 |
合計ジャッジ時間 | 7,088 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 TLE * 1 -- * 8 |
ソースコード
import sys import heapq sys.set_int_max_str_digits(0) def d(x): return sum(int(c) for c in x) n = int(input()) x = list(map(int, input().split())) # ヒープキューを使って桁数の短いものから処理 heap = [str(num) for num in x] heapq.heapify(heap) while len(heap) > 1: # 一番短い2つを取り出して掛け算 a = heapq.heappop(heap) b = heapq.heappop(heap) product = str(int(a) * int(b)) # 結果をヒープに戻す(ソートの基準を桁数にする) heapq.heappush(heap, product) y = heap[0] # 桁数が1になるまで桁和を取る while len(y) != 1: y = str(d(y)) print(y)