結果

問題 No.885 アマリクエリ
ユーザー Kiri8128Kiri8128
提出日時 2021-04-05 02:27:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 922 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 95,872 KB
最終ジャッジ日時 2023-08-28 13:50:32
合計ジャッジ時間 8,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 922 ms
92,416 KB
testcase_01 AC 415 ms
89,952 KB
testcase_02 AC 200 ms
92,564 KB
testcase_03 AC 183 ms
92,704 KB
testcase_04 AC 188 ms
92,588 KB
testcase_05 AC 131 ms
92,956 KB
testcase_06 AC 123 ms
95,872 KB
testcase_07 AC 101 ms
92,136 KB
testcase_08 AC 111 ms
87,008 KB
testcase_09 AC 438 ms
92,876 KB
testcase_10 AC 75 ms
71,236 KB
testcase_11 AC 75 ms
71,348 KB
testcase_12 AC 75 ms
71,128 KB
testcase_13 AC 119 ms
77,452 KB
testcase_14 AC 118 ms
77,984 KB
testcase_15 AC 119 ms
77,548 KB
testcase_16 AC 96 ms
76,188 KB
testcase_17 AC 84 ms
75,532 KB
testcase_18 AC 96 ms
75,964 KB
testcase_19 AC 77 ms
71,180 KB
testcase_20 AC 85 ms
75,340 KB
testcase_21 AC 93 ms
75,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heappush, heappop
H = []
hpush = lambda x: heappush(H, -x)
hpop = lambda: -heappop(H)
N = int(input())
A = [int(a) for a in input().split()]
ans = 0
for a in A:
    ans += a
    hpush(a)

Q = int(input())
X = [int(a) for a in input().split()]
for x in X:
    while -H[0] >= x:
        a = hpop()
        ans -= a
        a %= x
        hpush(a)
        ans += a
    print(ans)
    
0