結果

問題 No.885 アマリクエリ
ユーザー vwxyzvwxyz
提出日時 2024-04-10 08:59:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,052 ms / 2,000 ms
コード長 1,065 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 105,776 KB
最終ジャッジ日時 2024-04-10 08:59:53
合計ジャッジ時間 8,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,052 ms
104,968 KB
testcase_01 AC 507 ms
105,440 KB
testcase_02 AC 285 ms
105,264 KB
testcase_03 AC 317 ms
105,612 KB
testcase_04 AC 264 ms
105,472 KB
testcase_05 AC 206 ms
105,776 KB
testcase_06 AC 200 ms
102,768 KB
testcase_07 AC 191 ms
105,564 KB
testcase_08 AC 182 ms
103,260 KB
testcase_09 AC 543 ms
105,536 KB
testcase_10 AC 188 ms
89,708 KB
testcase_11 AC 146 ms
89,804 KB
testcase_12 AC 147 ms
89,768 KB
testcase_13 AC 179 ms
90,944 KB
testcase_14 AC 182 ms
91,172 KB
testcase_15 AC 181 ms
91,436 KB
testcase_16 AC 166 ms
90,372 KB
testcase_17 AC 155 ms
89,900 KB
testcase_18 AC 163 ms
90,468 KB
testcase_19 AC 151 ms
90,024 KB
testcase_20 AC 212 ms
90,132 KB
testcase_21 AC 165 ms
90,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N=int(input())
queue=list(map(int,input().split()))
_heapify_max(queue)
ans=sum(queue)
Q=int(input())
for x in map(int,input().split()):
    while queue[0]>=x:
        a=_heappop_max(queue)
        ans-=a
        a%=x
        _heappush_max(queue,a)
        ans+=a
    print(ans)
0