結果

問題 No.885 アマリクエリ
ユーザー hedwig100hedwig100
提出日時 2020-05-17 15:59:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 953 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 102,184 KB
最終ジャッジ日時 2023-10-26 00:16:03
合計ジャッジ時間 6,490 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 953 ms
100,404 KB
testcase_01 AC 372 ms
95,696 KB
testcase_02 AC 173 ms
95,464 KB
testcase_03 AC 156 ms
95,792 KB
testcase_04 AC 155 ms
95,104 KB
testcase_05 AC 106 ms
100,796 KB
testcase_06 AC 101 ms
102,184 KB
testcase_07 AC 97 ms
90,364 KB
testcase_08 AC 71 ms
88,376 KB
testcase_09 AC 424 ms
95,692 KB
testcase_10 AC 40 ms
53,512 KB
testcase_11 AC 40 ms
53,512 KB
testcase_12 AC 39 ms
53,512 KB
testcase_13 AC 73 ms
73,864 KB
testcase_14 AC 76 ms
73,992 KB
testcase_15 AC 72 ms
73,748 KB
testcase_16 AC 56 ms
66,164 KB
testcase_17 AC 44 ms
59,516 KB
testcase_18 AC 55 ms
66,164 KB
testcase_19 AC 43 ms
59,204 KB
testcase_20 AC 40 ms
53,512 KB
testcase_21 AC 55 ms
65,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = 10 ** 15
from heapq import  heapify,heappop,heappush

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A = [-a for a in A]
    Q = int(input())
    X = list(map(int,input().split()))
    
    ans = [0] * (Q + 1)
    ans[0] = -sum(A)
    heapify(A)
    for i,q in enumerate(X):
        while -A[0] >= q:
            a = -heappop(A)
            ans[i] -= (a//q) * q
            a %= q
            heappush(A,-a)
        ans[i + 1] = ans[i]
    print('\n'.join(map(str,ans[:-1])))
if __name__ == '__main__':
    main()

0