結果

問題 No.885 アマリクエリ
ユーザー hedwig100hedwig100
提出日時 2020-05-17 15:59:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 639 bytes
コンパイル時間 1,016 ms
コンパイル使用メモリ 11,796 KB
実行使用メモリ 27,820 KB
最終ジャッジ日時 2023-10-26 00:15:31
合計ジャッジ時間 10,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 604 ms
27,328 KB
testcase_02 AC 193 ms
27,820 KB
testcase_03 AC 199 ms
25,848 KB
testcase_04 AC 200 ms
26,112 KB
testcase_05 AC 106 ms
23,488 KB
testcase_06 AC 95 ms
20,468 KB
testcase_07 AC 67 ms
20,844 KB
testcase_08 AC 84 ms
22,412 KB
testcase_09 AC 621 ms
27,328 KB
testcase_10 AC 28 ms
10,008 KB
testcase_11 AC 28 ms
10,008 KB
testcase_12 AC 28 ms
10,008 KB
testcase_13 AC 30 ms
10,192 KB
testcase_14 AC 30 ms
10,192 KB
testcase_15 AC 31 ms
10,192 KB
testcase_16 AC 28 ms
10,192 KB
testcase_17 AC 28 ms
10,204 KB
testcase_18 AC 29 ms
10,196 KB
testcase_19 AC 27 ms
10,128 KB
testcase_20 AC 28 ms
10,128 KB
testcase_21 AC 29 ms
10,128 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