結果

問題 No.885 アマリクエリ
ユーザー qibqib
提出日時 2022-11-01 01:56:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,045 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 101,644 KB
最終ジャッジ日時 2023-09-22 22:37:36
合計ジャッジ時間 9,796 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,045 ms
100,956 KB
testcase_01 AC 472 ms
94,528 KB
testcase_02 AC 268 ms
100,040 KB
testcase_03 AC 226 ms
99,752 KB
testcase_04 AC 222 ms
99,988 KB
testcase_05 AC 165 ms
101,644 KB
testcase_06 AC 159 ms
98,172 KB
testcase_07 AC 107 ms
91,744 KB
testcase_08 AC 139 ms
91,516 KB
testcase_09 AC 462 ms
94,948 KB
testcase_10 AC 76 ms
71,168 KB
testcase_11 AC 75 ms
71,140 KB
testcase_12 AC 74 ms
71,392 KB
testcase_13 AC 123 ms
77,896 KB
testcase_14 AC 128 ms
77,612 KB
testcase_15 AC 122 ms
77,460 KB
testcase_16 AC 99 ms
76,392 KB
testcase_17 AC 94 ms
76,436 KB
testcase_18 AC 106 ms
76,888 KB
testcase_19 AC 78 ms
71,412 KB
testcase_20 AC 89 ms
75,988 KB
testcase_21 AC 90 ms
75,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())
a = list(map(int, input().split()))
q = int(input())
x = list(map(int, input().split()))

ans = 0
hp = []
for i in range(n):
  ans += a[i]
  heapq.heappush(hp, - a[i])

for i in range(q):
  while True:
    cur = heapq.heappop(hp)
    if - cur < x[i]:
      heapq.heappush(hp, cur)
      break
    else:
      ans -= (- cur)
      nxt = - ((- cur) % x[i])
      ans += (- nxt)
      heapq.heappush(hp, nxt)
  print(ans)
0