結果

問題 No.885 アマリクエリ
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-04-08 16:28:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 997 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 100,808 KB
最終ジャッジ日時 2024-04-14 13:33:49
合計ジャッジ時間 7,265 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 997 ms
94,148 KB
testcase_01 AC 469 ms
96,872 KB
testcase_02 AC 249 ms
96,644 KB
testcase_03 AC 194 ms
93,420 KB
testcase_04 AC 192 ms
93,420 KB
testcase_05 AC 142 ms
94,836 KB
testcase_06 AC 138 ms
100,808 KB
testcase_07 AC 101 ms
91,420 KB
testcase_08 AC 112 ms
90,444 KB
testcase_09 AC 472 ms
96,460 KB
testcase_10 AC 45 ms
55,760 KB
testcase_11 AC 45 ms
56,740 KB
testcase_12 AC 46 ms
55,564 KB
testcase_13 AC 96 ms
77,160 KB
testcase_14 AC 98 ms
77,232 KB
testcase_15 AC 94 ms
77,368 KB
testcase_16 AC 72 ms
73,568 KB
testcase_17 AC 62 ms
67,968 KB
testcase_18 AC 76 ms
73,580 KB
testcase_19 AC 51 ms
62,772 KB
testcase_20 AC 59 ms
66,492 KB
testcase_21 AC 63 ms
67,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
X = list(map(int,input().split()))
S = sum(A)
h = [-a for a in A]
heapify(h)
for i in range(Q):
    
    x = X[i]
    
    while True:
        
        y = heappop(h)
        y *= -1
        if y<x:
            heappush(h,-y)
            break
        
        S += (y%x - y)
        heappush(h,-(y%x))
    print(S)
0