結果

問題 No.885 アマリクエリ
ユーザー roarisroaris
提出日時 2020-12-02 19:29:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,012 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 99,408 KB
最終ジャッジ日時 2023-10-11 11:53:14
合計ジャッジ時間 8,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,012 ms
97,748 KB
testcase_01 AC 434 ms
95,144 KB
testcase_02 AC 204 ms
99,408 KB
testcase_03 AC 195 ms
98,984 KB
testcase_04 AC 197 ms
99,308 KB
testcase_05 AC 133 ms
96,148 KB
testcase_06 AC 126 ms
98,516 KB
testcase_07 AC 105 ms
90,860 KB
testcase_08 AC 118 ms
90,976 KB
testcase_09 AC 436 ms
95,712 KB
testcase_10 AC 76 ms
71,552 KB
testcase_11 AC 77 ms
71,556 KB
testcase_12 AC 78 ms
71,584 KB
testcase_13 AC 120 ms
77,828 KB
testcase_14 AC 119 ms
77,960 KB
testcase_15 AC 124 ms
78,016 KB
testcase_16 AC 102 ms
76,800 KB
testcase_17 AC 88 ms
76,440 KB
testcase_18 AC 103 ms
76,380 KB
testcase_19 AC 80 ms
71,588 KB
testcase_20 AC 86 ms
75,244 KB
testcase_21 AC 94 ms
76,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

N = int(input())
A = list(map(int, input().split()))
ans = 0
pq = []

for Ai in A:
    ans += Ai
    heappush(pq, -Ai)

Q = int(input())
X = list(map(int, input().split()))

for Xi in X:
    while -pq[0]>=Xi:
        v = -heappop(pq)
        ans -= v
        heappush(pq, -(v%Xi))
        ans += v%Xi
    
    print(ans)
0